From 50f90edcd6c480cf157b74be591b6757ea558fa6 Mon Sep 17 00:00:00 2001 From: Dmitry Ratushnyy <132273757+dmitry-ratushnyy@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:15:12 +0100 Subject: [PATCH] Fix publishing job (#30) * Fix publishing workflow * Add workflow for publishing beta * Do not limit branches for manual beta publishing * Reformat file --- .github/workflows/publish.yaml | 4 +-- .github/workflows/publish_beta.yaml | 45 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish_beta.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e8d1f1c..d35a741 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,4 +1,4 @@ -name: Publish ROCK +name: Publish ROCK (edge) on: push: branches: @@ -39,7 +39,7 @@ jobs: password: ${{ secrets.GHCR_TOKEN }} - name: Import and push to GHCR run: | - version=$(yq '(.version|split("-"))[0]' rockcraft.yaml) + version=$(yq '(.version)' rockcraft.yaml) base=$(yq '(.base|split("@"))[1]' rockcraft.yaml) tag=${version}-${base}_edge sudo skopeo --insecure-policy copy \ diff --git a/.github/workflows/publish_beta.yaml b/.github/workflows/publish_beta.yaml new file mode 100644 index 0000000..c6e3be8 --- /dev/null +++ b/.github/workflows/publish_beta.yaml @@ -0,0 +1,45 @@ +name: Publish ROCK (beta) +on: workflow_dispatch + +jobs: + build: + uses: ./.github/workflows/build.yaml + publish: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup Docker + run: | + sudo snap install docker + sudo addgroup --system docker; sudo adduser $USER docker + newgrp docker + sudo snap disable docker; sudo snap enable docker + - name: Install skopeo + run: | + sudo snap install --devmode --channel edge skopeo + - name: Install yq + run: | + sudo snap install yq + - uses: actions/download-artifact@v3 + with: + name: mongodb-rock + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Import and push to GHCR + run: | + version=$(yq '(.version)' rockcraft.yaml) + base=$(yq '(.base|split("@"))[1]' rockcraft.yaml) + tag=${version}-${base}_beta + sudo skopeo --insecure-policy copy \ + oci-archive:charmed-mongodb_${version}_amd64.rock \ + docker-daemon:ghcr.io/canonical/charmed-mongodb:${tag} + docker push ghcr.io/canonical/charmed-mongodb:${tag}