diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556536e..255cf8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,41 @@ jobs: env: DEBUG_OUTPUT: ${{ steps.run.outputs.debug_output }} + create-tag: + name: Create Version Tag + needs: build + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + filter: blob:none + + - name: Get version + uses: ./ + id: version + + - name: Check if tag exists + id: check + run: | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Create and push tag + if: steps.check.outputs.exists == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" + git push origin "v${{ steps.version.outputs.version }}" + release: name: Publish Release needs: build diff --git a/readme.md b/readme.md index 7466284..b050892 100644 --- a/readme.md +++ b/readme.md @@ -182,7 +182,8 @@ zero to pull the full history and tags. - name: Checkout uses: actions/checkout@v2 with: - fetch-depth: 0 + fetch-depth: 0 # fetch all history + filter: blob:none # exclude file contents for faster checkout ``` Alternatively, you can set this number to a value high enough to pull all the commits