Skip to content

Commit

Permalink
Fix release pipeline of Rock (#38)
Browse files Browse the repository at this point in the history
* try opensearch release pattern

* remove tests

* update to run on PR

* fix build + release

* add build workflow

* properly use github workflow

* fix full version of rock

* fix full version of rock

* set the right pipeline trigger

---------

Co-authored-by: Mehdi-Bendriss <[email protected]>
  • Loading branch information
MiaAltieri and Mehdi-Bendriss authored Jul 19, 2024
1 parent 75be67e commit 60b6b24
Showing 1 changed file with 65 additions and 12 deletions.
77 changes: 65 additions & 12 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
name: Release to GHCR
name: Publish to GHCR

env:
RELEASE: edge

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -17,12 +18,64 @@ jobs:
name: Build rock
uses: canonical/data-platform-workflows/.github/workflows/build_rock.yaml@v16

release:
name: Release rock
needs:
- build
uses: canonical/data-platform-workflows/.github/workflows/release_rock.yaml@v16
with:
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
permissions:
packages: write # Needed to publish to GitHub Container Registry
publish:
needs: build
name: publish
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install required dependencies
run: |
# docker
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
# skopeo
sudo snap install --devmode --channel edge skopeo
# yq
sudo snap install yq
- name: Download rock package(s)
uses: actions/download-artifact@v4
with:
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
merge-multiple: true

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Publish rock to Store
run: |
full_version="$(cat rockcraft.yaml | yq .version)"
version="${full_version%-*}"
base="$(cat rockcraft.yaml | yq .base)"
base="${base#*@}"
# push major version to edge
major_tag_version="${version%%.*}-${{ env.RELEASE }}"
sudo skopeo \
--insecure-policy \
copy \
oci-archive:charmed-mongodb_${full_version}_amd64.rock \
docker-daemon:ghcr.io/canonical/charmed-mongodb:${major_tag_version}
docker push ghcr.io/canonical/charmed-mongodb:${major_tag_version}
### push full version to edge
tag_version="${version}-${base}_${{ env.RELEASE }}"
echo "Publishing charmed-mongodb:${tag_version}"
sudo skopeo \
--insecure-policy \
copy \
oci-archive:charmed-mongodb_${full_version}_amd64.rock \
docker-daemon:ghcr.io/canonical/charmed-mongodb:${tag_version}
docker push ghcr.io/canonical/charmed-mongodb:${tag_version}

0 comments on commit 60b6b24

Please sign in to comment.