From 5cb7cb41b746cdd0e536e33604a310aa56235d87 Mon Sep 17 00:00:00 2001 From: Lasse Alm Date: Wed, 24 Jul 2024 16:32:25 +0200 Subject: [PATCH] standardised the recover id object workflow --- .../workflows/release-recover-id-object.yml | 56 +++++++++++++++++++ .github/workflows/release.yml | 39 ------------- 2 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/release-recover-id-object.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-recover-id-object.yml b/.github/workflows/release-recover-id-object.yml new file mode 100644 index 00000000..ab7c0e9b --- /dev/null +++ b/.github/workflows/release-recover-id-object.yml @@ -0,0 +1,56 @@ +name: Publish Docker image for recover-id-object to DockerHub + +on: + push: + tags: + - 'recover-id-object/*.*.*' + +env: + REGISTRY: docker.io + IMAGE_NAME: recover-id-object + RUST_VERSION: rust:1.74-buster # Define the Rust version here + +jobs: + publish-docker-image: + runs-on: ubuntu-latest + environment: release-recover-id-object + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Extract version tag from Cargo.toml manifest + id: meta + run: | + VERSION=$(yq .package.version recover-id-object/Cargo.toml) + FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/${{ env.IMAGE_NAME }}:$VERSION" + echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}" + # Make sure the image does not exist. Abort if we can retrieve any metadata. + if docker manifest inspect $FULL_IMAGE_TAG > /dev/null; then + echo "::error $FULL_IMAGE_TAG already exists" + exit 1 + elif [ ! "${{ github.ref_name }}" = "recover-id-object/${VERSION}" ]; then + echo "::error Expected tag ${EXPECTED_TAG} does not match the version ${VERSION}." + exit 1 + else + # Store the full image tag into a tag variable for the following step. + echo "tag=${FULL_IMAGE_TAG}" > "$GITHUB_OUTPUT" + fi + echo "tag=$FULL_IMAGE_TAG" >> $GITHUB_ENV + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: recover-id-object/scripts/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tag }} + build-args: | + BUILD_IMAGE=${{ env.RUST_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4d9b7726..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release workflow - -on: - workflow_dispatch: - -env: - RUST_VERSION: rust:1.74-buster - -jobs: - - build-and-push: - runs-on: ubuntu-latest - environment: release-recover-id-object - steps: - - name: Check out the repo - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Log in to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Extract Cargo package version - run: | - cd recover-id-object - VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - echo "VERSION=$VERSION" >> $GITHUB_ENV - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: recover-id-object/scripts/Dockerfile - push: true - build-args: | - build_image=${{ env.RUST_VERSION }} - tags: concordium/recover-id-object:${{ env.VERSION}}