From 28f81d99d06ec4eb59e7a2575be3086b7e67a05f Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Fri, 19 Jul 2024 16:31:34 +0000 Subject: [PATCH] fix build + release --- .github/workflows/publish.yaml | 58 +++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 51b4bcf..919306e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -11,6 +11,7 @@ on: jobs: publish: + needs: build name: publish runs-on: ubuntu-latest timeout-minutes: 15 @@ -32,11 +33,9 @@ jobs: # yq sudo snap install yq - - name: Download rock file - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v3 with: - name: charmed_mongodb_rock_amd64 - path: . + name: mongodb-rock - name: Login to GitHub Container Registry uses: docker/login-action@v2 @@ -70,3 +69,54 @@ jobs: oci-archive:charmed-mongodb_${version}_amd64.rock \ docker-daemon:ghcr.io/canonical/charmed-mongodb:${tag_version} docker push ghcr.io/canonical/charmed-mongodb:${tag_version} + + +name: Publish rock (edge) +on: + push: + branches: + - '[0-9]-[0-9][0-9].[0-9][0-9]' + +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|split("-"))[0]' rockcraft.yaml) + rock_image_version=$(yq '(.version)' rockcraft.yaml) + base=$(yq '(.base|split("@"))[1]' rockcraft.yaml) + tag=${version}-${base}_edge + sudo skopeo --insecure-policy copy \ + oci-archive:charmed-mongodb_${rock_image_version}_amd64.rock \ + docker-daemon:ghcr.io/canonical/charmed-mongodb:${tag} + docker push ghcr.io/canonical/charmed-mongodb:${tag} \ No newline at end of file