Skip to content

Release

Release #24

Workflow file for this run

# Prepares, builds and publishes new releases
name: Release
# On changes to release branches
on:
push:
branches:
- main
- master
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: 🙌 Prepare release
id: release
uses: googleapis/release-please-action@v4
with:
config-file: .github/release-please.json
token: ${{ secrets.GITHUB_TOKEN }}
- name: ✨ Checkout repository
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
- name: 🏷️ Tag major and minor versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/axieum/hln-a.git"
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push gh-token :v${{ steps.release.outputs.major }} || true
git push gh-token :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git tag -a v${{ steps.release.outputs.major }} -m "chore: release v${{ steps.release.outputs.major }}"
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "chore: release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
git push gh-token v${{ steps.release.outputs.major }}
git push gh-token v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
build-and-push-image:
name: Push
needs: [ release ]
if: ${{ needs.release.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: ✨ Checkout repository
uses: actions/checkout@v4
- name: 🛡️ Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 📦 Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=semver,pattern={{version}},value=${{ needs.release.outputs.tag_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.tag_name }}
type=semver,pattern={{major}},value=${{ needs.release.outputs.tag_name }}
- name: 🚢 Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: ✒️ Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true