|
| 1 | +--- |
| 2 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json |
| 3 | +name: Create tag |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + determine-tag-version: |
| 17 | + name: Determine tag version |
| 18 | + if: github.ref == 'refs/heads/main' |
| 19 | + runs-on: ubuntu-24.04 |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + outputs: |
| 23 | + tag_version: ${{ steps.git-cliff.outputs.tag_version }} |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + persist-credentials: false |
| 30 | + |
| 31 | + - name: Install git-cliff |
| 32 | + uses: taiki-e/install-action@cede0bb282aae847dfa8aacca3a41c86d973d4d7 # v2.68.1 |
| 33 | + with: |
| 34 | + tool: git-cliff |
| 35 | + |
| 36 | + - name: Get tag version |
| 37 | + id: git-cliff |
| 38 | + run: | |
| 39 | + tag_version=$(git-cliff -c .github/cliff.toml --bumped-version --unreleased) |
| 40 | + echo "Next tag version is ${tag_version}" |
| 41 | + echo "tag_version=${tag_version}" >> "$GITHUB_OUTPUT" |
| 42 | +
|
| 43 | + create-tag: |
| 44 | + name: Create tag |
| 45 | + if: github.ref == 'refs/heads/main' |
| 46 | + runs-on: ubuntu-24.04 |
| 47 | + permissions: |
| 48 | + contents: write |
| 49 | + needs: determine-tag-version |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + TAG_VERSION: ${{ needs.determine-tag-version.outputs.tag_version }} |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 |
| 56 | + with: |
| 57 | + ssh-key: '${{ secrets.COMMIT_KEY }}' |
| 58 | + |
| 59 | + - name: Pnpm Setup |
| 60 | + uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 |
| 61 | + |
| 62 | + - name: Set up Node.js |
| 63 | + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 |
| 64 | + with: |
| 65 | + node-version-file: 'package.json' |
| 66 | + # For workflows with elevated privileges we recommend disabling automatic caching. |
| 67 | + # https://github.com/actions/setup-node |
| 68 | + package-manager-cache: false |
| 69 | + |
| 70 | + - name: Configure git |
| 71 | + run: | |
| 72 | + git config --global user.name "${{ github.actor }}" |
| 73 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 74 | +
|
| 75 | + - name: Bump package.json |
| 76 | + run: npm version ${TAG_VERSION} --no-commit-hooks --no-git-tag-version |
| 77 | + |
| 78 | + - name: Commit updated files |
| 79 | + run: | |
| 80 | + git add package.json |
| 81 | + git commit -m 'chore(release): prepare ${TAG_VERSION}' |
| 82 | + git push |
| 83 | +
|
| 84 | + - name: Create git tag |
| 85 | + run: | |
| 86 | + git tag ${TAG_VERSION} |
| 87 | + git push origin ${TAG_VERSION} |
0 commit comments