From 3993b08f02d0419f87cf314463ebcf443ec5d768 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Fri, 3 May 2024 15:07:19 +0200 Subject: [PATCH 1/2] Add new release and promote workflow Using official actions directly. --- .github/workflows/promote.yaml | 25 +++++++++++++++++++++ .github/workflows/release.yaml | 41 ++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/promote.yaml diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml new file mode 100644 index 0000000..011895e --- /dev/null +++ b/.github/workflows/promote.yaml @@ -0,0 +1,25 @@ +name: Promote charm 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-charm: + name: Promote charm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Release charm to channel + uses: canonical/charming-actions/release-charm@2.4.0 + with: + credentials: ${{ secrets.CHARMHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + destination-channel: ${{ github.event.inputs.destination-channel }} + origin-channel: ${{ github.event.inputs.origin-channel }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 309562b..2076532 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,25 +1,38 @@ -# This is a template `release.yaml` file for ops charms -# This file is managed by bootstack-charms-spec and should not be modified -# within individual charm repos. https://launchpad.net/bootstack-charms-spec - name: Release to Edge on: push: - branches: [master, main] - -concurrency: - group: release - cancel-in-progress: true + branches: [ main ] + release: + types: [ published ] jobs: check: uses: ./.github/workflows/check.yaml + secrets: inherit release: needs: check - uses: canonical/bootstack-actions/.github/workflows/charm-release.yaml@v2 - secrets: inherit - with: - channel: "latest/edge" - upload-image: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Initialize lxd # This should dropped once it's implemented on charming-actions itself. https://github.com/canonical/charming-actions/issues/140 + if: ${{ inputs.destructive-mode == false }} + run: | + sudo lxd init --auto + # The following is needed to fix network error when creating new base instance on lxd + sudo chmod a+wr /var/snap/lxd/common/lxd/unix.socket + lxc network set lxdbr0 ipv6.address none + sudo usermod -a -G lxd $USER + if [[ $(cat /etc/os-release | grep VERSION_CODENAME) == *"jammy"* ]]; then + sudo iptables -F FORWARD + sudo iptables -P FORWARD ACCEPT + fi + - name: Upload charm to charmhub + uses: canonical/charming-actions/upload-charm@2.4.0 + with: + credentials: "${{ secrets.CHARMHUB_TOKEN }}" + github-token: "${{ secrets.GITHUB_TOKEN }}" + channel: "latest/edge" + destructive-mode: false From 948f2ec6cafa876dca5c5df1e53358dd8a0a7250 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Mon, 6 May 2024 15:49:32 +0200 Subject: [PATCH 2/2] apply suggestions --- .github/workflows/promote.yaml | 4 ++-- .github/workflows/release.yaml | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index 011895e..aa53c2e 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: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2076532..3b01e7e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,21 +18,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Initialize lxd # This should dropped once it's implemented on charming-actions itself. https://github.com/canonical/charming-actions/issues/140 - if: ${{ inputs.destructive-mode == false }} - run: | - sudo lxd init --auto - # The following is needed to fix network error when creating new base instance on lxd - sudo chmod a+wr /var/snap/lxd/common/lxd/unix.socket - lxc network set lxdbr0 ipv6.address none - sudo usermod -a -G lxd $USER - if [[ $(cat /etc/os-release | grep VERSION_CODENAME) == *"jammy"* ]]; then - sudo iptables -F FORWARD - sudo iptables -P FORWARD ACCEPT - fi + uses: canonical/setup-lxd@v0.1.1 - name: Upload charm to charmhub uses: canonical/charming-actions/upload-charm@2.4.0 with: credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" channel: "latest/edge" + # Note(rgildein): Right now we are not using destructive-mode, since our charmcraft.yaml is designed with a single build-on and the ability to run-on multiple bases. Running with destructive-mode would require aligning the base defined in this job with the one defined in charmcraft.yaml (build-on). destructive-mode: false