|
5 | 5 | tags: |
6 | 6 | - 'v*' |
7 | 7 | workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Version tag to create and release (e.g. v1.2.3)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: release |
| 16 | + cancel-in-progress: false |
8 | 17 |
|
9 | 18 | jobs: |
| 19 | + tag: |
| 20 | + name: Create and Push Tag |
| 21 | + if: github.event_name == 'workflow_dispatch' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: write |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Validate version format |
| 28 | + env: |
| 29 | + VERSION: ${{ github.event.inputs.version }} |
| 30 | + run: | |
| 31 | + if ! echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then |
| 32 | + echo "ERROR: Version must match vX.Y.Z format (e.g. v1.2.3)" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + - name: Verify tag does not already exist |
| 36 | + env: |
| 37 | + VERSION: ${{ github.event.inputs.version }} |
| 38 | + run: | |
| 39 | + if git ls-remote --tags origin "refs/tags/$VERSION" | grep -qF "$VERSION"; then |
| 40 | + echo "ERROR: Tag $VERSION already exists on remote. Aborting." |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + - name: Create and push tag |
| 44 | + env: |
| 45 | + VERSION: ${{ github.event.inputs.version }} |
| 46 | + run: | |
| 47 | + git config user.name "github-actions[bot]" |
| 48 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 49 | + git tag "$VERSION" |
| 50 | + git push origin "$VERSION" |
| 51 | +
|
10 | 52 | test: |
11 | 53 | name: Test (${{ matrix.os }}) |
| 54 | + needs: [tag] |
| 55 | + if: "!cancelled() && (needs.tag.result == 'success' || needs.tag.result == 'skipped')" |
12 | 56 | runs-on: ${{ matrix.os }} |
13 | 57 | strategy: |
14 | 58 | matrix: |
@@ -67,13 +111,14 @@ jobs: |
67 | 111 |
|
68 | 112 | release: |
69 | 113 | name: Publish GitHub Release |
70 | | - if: startsWith(github.ref, 'refs/tags/') |
71 | 114 | needs: build |
| 115 | + if: "!cancelled() && needs.build.result == 'success'" |
72 | 116 | runs-on: ubuntu-latest |
73 | 117 | permissions: |
74 | 118 | contents: write |
75 | 119 | steps: |
76 | 120 | - uses: actions/download-artifact@v4 |
77 | 121 | - uses: softprops/action-gh-release@v2 |
78 | 122 | with: |
| 123 | + tag_name: ${{ github.event.inputs.version || github.ref_name }} |
79 | 124 | files: cship-*/cship-* |
0 commit comments