|
1 | | -# shared-workflows/.github/workflows/nbgv_prepare_release.yml |
2 | 1 | name: NBGV Prepare Release |
3 | 2 |
|
4 | 3 | on: |
5 | 4 | workflow_call: |
6 | 5 | inputs: |
7 | 6 | target_branch: |
8 | | - description: "Branch or tag to release from" |
9 | 7 | type: string |
10 | 8 | required: true |
11 | 9 | default: main |
12 | 10 | increment: |
13 | | - description: "Version increment (major | minor | patch)" |
14 | 11 | type: string |
15 | 12 | required: true |
16 | 13 | default: patch |
17 | 14 | secrets: |
18 | 15 | GH_TOKEN: |
19 | | - description: "GitHub token (falls back to github.token if not provided)" |
20 | 16 | required: false |
21 | 17 |
|
22 | 18 | jobs: |
23 | 19 | prep: |
24 | 20 | runs-on: ubuntu-latest |
25 | | - env: |
26 | | - GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} |
27 | 21 | steps: |
28 | 22 | - name: 📥 Checkout target branch |
29 | 23 | uses: actions/checkout@v4 |
30 | 24 | with: |
31 | 25 | ref: ${{ inputs.target_branch }} |
32 | 26 | fetch-depth: 0 |
33 | | - token: ${{ env.GH_TOKEN }} |
| 27 | + token: ${{ secrets.GH_TOKEN || github.token }} |
34 | 28 |
|
35 | | - - name: ⚙️ Setup .NET 9.0 |
| 29 | + - name: ⚙️ Setup .NET & restore NBGV |
36 | 30 | uses: actions/setup-dotnet@v4 |
37 | 31 | with: |
38 | 32 | dotnet-version: "9.0.x" |
| 33 | + - run: dotnet tool restore |
39 | 34 |
|
40 | | - - name: 🛠️ Bump version & create branch |
41 | | - id: nbgv |
42 | | - uses: dotnet/nbgv@master |
43 | | - with: |
44 | | - version-increment: ${{ inputs.increment }} # major | minor | patch |
45 | | - version-file: version.json # explicitly point at your file |
| 35 | + - name: 🖊️ Inject omitCommitId into version.json |
| 36 | + run: | |
| 37 | + # Backup and rewrite version.json to include omitCommitId=true |
| 38 | + jq '.release +={"omitCommitId": true}' version.json > version.tmp.json |
| 39 | + mv version.tmp.json version.json |
| 40 | +
|
| 41 | + - name: 🗂️ Prepare release |
| 42 | + id: prepare |
| 43 | + run: | |
| 44 | + git config user.name "release-bot" |
| 45 | + git config user.email "release-bot@users.noreply.github.com" |
| 46 | +
|
| 47 | + INC=${{ inputs.increment }} |
| 48 | + case "$INC" in |
| 49 | + major) FLAGS="--versionIncrement major" ;; |
| 50 | + minor) FLAGS="--versionIncrement minor" ;; |
| 51 | + patch) FLAGS="" ;; |
| 52 | + esac |
| 53 | +
|
| 54 | + dotnet nbgv prepare-release --project "$GITHUB_WORKSPACE" $FLAGS |
| 55 | +
|
| 56 | + echo "release_branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT" |
46 | 57 |
|
47 | 58 | outputs: |
48 | | - release_branch: ${{ steps.nbgv.outputs.BranchName }} |
| 59 | + release_branch: ${{ steps.prepare.outputs.release_branch }} |
0 commit comments