From b9d104e33c986687236b2de576e2266812f807db Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Fri, 3 May 2024 15:36:13 +0200 Subject: [PATCH 1/6] Add new release and promote workflow Using official actions directly. --- .github/workflows/promote.yaml | 36 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 32 ++++++++++++++++++++++++++++++ 2 files changed, 68 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..412c64d3 --- /dev/null +++ b/.github/workflows/promote.yaml @@ -0,0 +1,36 @@ +name: Promote snap to other tracks and channels + +on: + workflow_dispatch: + inputs: + destination-channel: + description: 'Destination Channel' + required: true + origin-channel: + description: 'Origin Channel' + required: true + +jobs: + promote-snap: + name: Promote snap + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install yq + run: sudo snap install yq + - name: Snapcraft install + run: sudo snap install --classic snapcraft + - name: Get snap name + id: snap + run: echo "name=$(yq '.name' 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..b4a6322a --- /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,3/edge From 740f4bb33096fece356669277c07a6ac8090c1e9 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Mon, 6 May 2024 16:15:49 +0200 Subject: [PATCH 2/6] apply suggestions --- .github/workflows/promote.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index 412c64d3..8f04191c 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -4,10 +4,10 @@ on: workflow_dispatch: inputs: destination-channel: - description: 'Destination Channel' + description: 'Destination Channel, e.g. latest/candidate' required: true origin-channel: - description: 'Origin Channel' + description: 'Origin Channel, e.g. latest/edge' required: true jobs: From 9b5d1c6b3caf9ed2cd064e0cc71c487704f42078 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Mon, 6 May 2024 21:16:35 +0200 Subject: [PATCH 3/6] Update .github/workflows/promote.yaml Co-authored-by: Andrea Ieri --- .github/workflows/promote.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index 8f04191c..e0a7711c 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -16,13 +16,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install yq - run: sudo snap install yq - name: Snapcraft install run: sudo snap install --classic snapcraft - name: Get snap name id: snap - run: echo "name=$(yq '.name' snap/snapcraft.yaml)" >> $GITHUB_OUTPUT + run: grep -Po '(?<=^name:)\s*\K\w+' snap/snapcraft.yaml >> $GITHUB_OUTPUT - name: Snapcraft promote snap env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} From d10499e36d02c885ab6fc8ee0397206a951bc6ce Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 7 May 2024 10:53:08 +0200 Subject: [PATCH 4/6] update step to get snap name --- .github/workflows/promote.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index e0a7711c..537a02b6 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -20,7 +20,7 @@ jobs: run: sudo snap install --classic snapcraft - name: Get snap name id: snap - run: grep -Po '(?<=^name:)\s*\K\w+' snap/snapcraft.yaml >> $GITHUB_OUTPUT + run: awk '/name:/ {print $2}' snap/snapcraft.yaml >> $GITHUB_OUTPUT - name: Snapcraft promote snap env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} From 3fe9a5ca811f884cce54c95debc43d92ddcbf2ba Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 7 May 2024 11:17:44 +0200 Subject: [PATCH 5/6] add suggestion --- .github/workflows/promote.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index 537a02b6..025bbe9d 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -20,7 +20,7 @@ jobs: run: sudo snap install --classic snapcraft - name: Get snap name id: snap - run: awk '/name:/ {print $2}' snap/snapcraft.yaml >> $GITHUB_OUTPUT + run: awk '/^name:/ {print $2}' snap/snapcraft.yaml >> $GITHUB_OUTPUT - name: Snapcraft promote snap env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} From e7dffb816b53120f705b2d74072095588e78ac70 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 7 May 2024 11:28:46 +0200 Subject: [PATCH 6/6] fix release channel --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b4a6322a..86ef81ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,4 +29,4 @@ jobs: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: snap: ${{ steps.build.outputs.snap }} - release: latest/edge,3/edge + release: latest/edge