From cf8e7ac7a217702d640e7f009d67d82c86d7b9d5 Mon Sep 17 00:00:00 2001 From: pgoslatara Date: Wed, 10 Jul 2024 10:18:24 +0200 Subject: [PATCH] Adding more tags to releases --- .github/workflows/release_pipeline.yml | 48 +++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release_pipeline.yml b/.github/workflows/release_pipeline.yml index 4b10dc59..d2eedf9a 100644 --- a/.github/workflows/release_pipeline.yml +++ b/.github/workflows/release_pipeline.yml @@ -31,9 +31,9 @@ if: github.actor != 'pgoslatara' run: exit 1 - - name: Only run from `main` - if: github.ref_name != github.event.repository.default_branch - run: exit 1 + # - name: Only run from `main` + # if: github.ref_name != github.event.repository.default_branch + # run: exit 1 - uses: actions/checkout@v4 @@ -70,14 +70,34 @@ - name: Save version to env var id: version - run: echo "version=$(poetry version --short)" >> $GITHUB_OUTPUT + run: | + echo "version=$(poetry version --short)" >> $GITHUB_OUTPUT + echo "major=$(echo $(poetry version --short | cut -d '.' -f 1))" >> $GITHUB_OUTPUT + echo "minor=$(echo $(poetry version --short | cut -d '.' -f 2))" >> $GITHUB_OUTPUT + echo "patch=$(echo $(poetry version --short | cut -d '.' -f 3))" >> $GITHUB_OUTPUT + + - name: Determine if prerelease flag is necessary + run: | + [ "${{ inputs.version_bump_type }}" = "prerelease" ] && export PRERELEASE="--prerelease" || export PRERELEASE="--latest" + echo "PRERELEASE: $PRERELEASE" + echo PRERELEASE=$PRERELEASE >> "$GITHUB_ENV" - name: Tag commit and push run: | - git config --globa user.email "bot@github.com" + git config --global 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 }}" + git tag \ + -a v${{ steps.version.outputs.version }} \ + -m "v${{ steps.version.outputs.version }}" + git push origin "v${{ steps.version.outputs.version }}" + git tag \ + -a v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }} \ + -m "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" + git push origin "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" + git tag \ + -a v${{ steps.version.outputs.major }} \ + -m "v${{ steps.version.outputs.major }}" + git push origin "v${{ steps.version.outputs.major }}" - name: Extract metadata (tags, labels) for Docker id: meta @@ -85,7 +105,9 @@ with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=${{ steps.version.outputs.version }} + type=raw,value=v${{ steps.version.outputs.version }} + type=raw,value=v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }} + type=raw,value=v${{ steps.version.outputs.major }} type=raw,value=${{ github.sha }} - name: Set up Docker Buildx @@ -117,20 +139,14 @@ push: true tags: ${{ steps.meta.outputs.tags }} - - name: Determine if prerelease flag is necessary - run: | - [ "${{ inputs.version_bump_type }}" = "prerelease" ] && export PRERELEASE="--prerelease" || export PRERELEASE="--latest" - echo "PRERELEASE: $PRERELEASE" - echo PRERELEASE=$PRERELEASE >> "$GITHUB_ENV" - - name: Create release env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ steps.version.outputs.version }} \ + gh release create v${{ steps.version.outputs.version }} \ --generate-notes \ --repo ${{ github.repository }} \ --target main \ - --title '${{ steps.version.outputs.version }}' \ + --title 'v${{ steps.version.outputs.version }}' \ $PRELEASE \ --verify-tag