From 96ded857d5c27d0903da5757f8801043e02bd5bd Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 7 May 2024 13:20:52 +0200 Subject: [PATCH] Add new release and promote workflow (#402) Using official actions directly. --------- Co-authored-by: Xuhui Zhu Co-authored-by: Andrea Ieri --- .github/workflows/promote.yaml | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/promote.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml new file mode 100644 index 00000000..025bbe9d --- /dev/null +++ b/.github/workflows/promote.yaml @@ -0,0 +1,34 @@ +name: Promote snap to other tracks and channels + +on: + workflow_dispatch: + inputs: + destination-channel: + description: 'Destination Channel, e.g. latest/candidate' + required: true + origin-channel: + description: 'Origin Channel, e.g. latest/edge' + required: true + +jobs: + promote-snap: + name: Promote snap + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Snapcraft install + run: sudo snap install --classic snapcraft + - name: Get snap name + id: snap + run: awk '/^name:/ {print $2}' snap/snapcraft.yaml >> $GITHUB_OUTPUT + - name: Snapcraft promote snap + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + SNAPCRAFT_HAS_TTY: "true" # this is necessary because snapcraft will not allow --yes for promotions of the edge channel https://github.com/canonical/snapcraft/issues/4439 + run: | + # Note: using `yes |` instead of `--yes` because snapcraft will + # refuse to non-interactively promote a snap from the edge + # channel if it is done without any branch qualifiers + yes | snapcraft promote ${{ steps.snap.outputs.name }} \ + --from-channel ${{ github.event.inputs.origin-channel }} \ + --to-channel ${{ github.event.inputs.destination-channel }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..86ef81ef --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +name: Publish snap + +on: + push: + branches: [ main ] + release: + types: [ published ] + +jobs: + check: + uses: ./.github/workflows/check.yaml + secrets: inherit + + release: + runs-on: ubuntu-latest + needs: check + outputs: + snap: ${{ steps.build.outputs.snap }} + steps: + - uses: actions/checkout@v4 + - uses: snapcore/action-build@v1 + id: build + - uses: actions/upload-artifact@v4 + with: + name: snap + path: ${{ steps.build.outputs.snap }} + - uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + with: + snap: ${{ steps.build.outputs.snap }} + release: latest/edge