Release v1.0.0.7: bump repo.json #490
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-tag on version bump | |
| # Whenever master moves, read the plugin version from Directory.Build.props. | |
| # If that version has no matching v* tag yet, create one and push it; the | |
| # existing release.yml fires from the tag push and publishes latest.zip. | |
| # | |
| # Bump <Version> in Directory.Build.props before (or inside) your PR and | |
| # you get a release automatically once it merges. Commit without a version | |
| # bump and nothing happens. CI also asserts repo.json's AssemblyVersion / | |
| # TestingAssemblyVersion match this value. | |
| # | |
| # The tag is pushed with HUB_REPO_PAT (a PAT with contents:write on this repo) | |
| # rather than the default GITHUB_TOKEN: tags pushed by GITHUB_TOKEN do NOT | |
| # cascade-trigger other workflows, so release.yml would otherwise need a manual | |
| # dispatch. With the PAT set, the tag push triggers release.yml automatically. | |
| # If the secret is unset the workflow falls back to GITHUB_TOKEN (tag still | |
| # created; release must then be dispatched via release.yml's workflow_dispatch). | |
| on: | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: auto-tag-master | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| if: "!contains(toJson(github.event.commits.*.message), '[skip auto-tag]')" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| # PAT so the tag push cascade-triggers release.yml; falls back to the | |
| # default token (no cascade) when the secret isn't configured. | |
| token: ${{ secrets.HUB_REPO_PAT || secrets.GITHUB_TOKEN }} | |
| - name: Read plugin version from Directory.Build.props | |
| id: version | |
| run: | | |
| version=$(grep -oP '<Version>\K[\d.]+(?=</Version>)' Directory.Build.props) | |
| if [ -z "$version" ]; then | |
| echo "::error::Could not parse <Version> from Directory.Build.props" | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$version" >> "$GITHUB_OUTPUT" | |
| echo "Plugin version: $version" | |
| - name: Check whether tag already exists | |
| id: check | |
| run: | | |
| tag="${{ steps.version.outputs.tag }}" | |
| if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "Tag $tag already exists; nothing to do." | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Tag $tag does not exist yet; will create." | |
| fi | |
| - name: Create and push tag | |
| if: steps.check.outputs.exists == 'false' | |
| env: | |
| TAG: ${{ steps.version.outputs.tag }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" -m "Release $TAG" | |
| if git push origin "$TAG"; then | |
| echo "Pushed tag $TAG." | |
| elif git ls-remote --tags origin "refs/tags/$TAG" | awk '{print $2}' | grep -qx "refs/tags/$TAG"; then | |
| echo "Tag $TAG was created by another run; nothing to do." | |
| else | |
| echo "::error::Failed to push tag $TAG" | |
| exit 1 | |
| fi |