feat: build, sign and publish registries #5736
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- "feature/**" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decision to Publish | |
id: decisions | |
run: | | |
# Secrets cannot be used in conditionals, so this is our dance: | |
# https://github.com/actions/runner/issues/520 | |
if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}" ]]; then | |
echo PUBLISH=true >> $GITHUB_OUTPUT | |
else | |
echo PUBLISH= >> $GITHUB_OUTPUT | |
fi | |
- if: steps.decisions.outputs.PUBLISH == 'true' | |
name: Checkout Snapcraft | |
uses: actions/checkout@v4 | |
with: | |
# Fetch all of history so Snapcraft can determine its own version from git. | |
fetch-depth: 0 | |
- if: steps.decisions.outputs.PUBLISH == 'true' | |
uses: canonical/action-build@v1 | |
name: Build Snapcraft Snap | |
id: build | |
with: | |
snapcraft-channel: latest/candidate | |
- if: steps.decisions.outputs.PUBLISH == 'true' | |
name: Verify Snapcraft Snap | |
run: | | |
# Make sure it is installable. | |
sudo snap install --dangerous --classic ${{ steps.build.outputs.snap }} | |
- name: Get branch name | |
id: vars | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request" ]] | |
then | |
echo "branch=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT" | |
else | |
branch=$(echo ${GITHUB_REF#refs/*/} | sed -e 's|feature/\(.*\)|\1|') | |
echo "branch=$branch" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Publish feature branch to edge/${{ steps.vars.outputs.branch }} | |
if: steps.decisions.outputs.PUBLISH == 'true' | |
uses: canonical/action-publish@v1 | |
env: | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | |
with: | |
snap: ${{ steps.build.outputs.snap }} | |
release: edge/${{ steps.vars.outputs.branch }} |