From d39a3adbc005dce3538ebf42242f2392d399311f Mon Sep 17 00:00:00 2001 From: pgoslatara Date: Sun, 30 Jun 2024 14:37:08 +0200 Subject: [PATCH] Tag commits during release --- .github/workflows/release_pipeline.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release_pipeline.yml b/.github/workflows/release_pipeline.yml index d25c766b..fbd09517 100644 --- a/.github/workflows/release_pipeline.yml +++ b/.github/workflows/release_pipeline.yml @@ -23,7 +23,7 @@ build-and-push-image: runs-on: ubuntu-latest permissions: - contents: read + contents: write id-token: write packages: write steps: @@ -33,6 +33,9 @@ - uses: actions/checkout@v4 + - name: Fetch tags + run: git fetch --prune --unshallow --tags + - name: Setup Python id: setup-python uses: actions/setup-python@v5 @@ -57,20 +60,29 @@ run: poetry self add poetry-bumpversion - name: Bump version - run: poetry version ${{ inputs.version_bump_type }} + run: | + poetry version $(git tag --sort version:refname | tail -n 1) + poetry version ${{ inputs.version_bump_type }} - name: Save version to env var id: version run: echo "version=$(poetry version --short)" >> $GITHUB_OUTPUT + - name: Tag commit and push + run: | + git config --globa user.email "bot@github.com" + git config --global user.name "github-actions[bot]" + git tag -a ${{ steps.version.outputs.version }} -m "${{ steps.version.outputs.version }}" + git push origin "${{ steps.version.outputs.version }}" + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=${{ github.sha }} type=raw,value=${{ steps.version.outputs.version }} + type=raw,value=${{ github.sha }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3