|
17 | 17 | required: true |
18 | 18 |
|
19 | 19 | permissions: |
20 | | - contents: write |
| 20 | + contents: write |
21 | 21 | pull-requests: write |
22 | | - packages: write |
| 22 | + packages: write |
23 | 23 |
|
24 | 24 | jobs: |
25 | 25 | validate_branch: |
26 | 26 | runs-on: ubuntu-latest |
27 | | - |
28 | | - |
29 | 27 | outputs: |
30 | 28 | version_json_path: ${{ steps.locate_version.outputs.file }} |
31 | | - |
32 | 29 | steps: |
33 | 30 | - name: Checkout target branch |
34 | 31 | uses: actions/checkout@v4 |
35 | 32 | with: |
36 | 33 | fetch-depth: 1 |
37 | 34 | ref: ${{ inputs.target_branch }} |
38 | 35 |
|
39 | | - # Optional sanity check (keeps the job obvious when the ref is wrong) |
40 | 36 | - name: Ensure target branch exists |
41 | 37 | run: | |
42 | 38 | if ! git rev-parse --verify --quiet "refs/heads/${{ inputs.target_branch }}"; then |
43 | 39 | echo "::error::Ref '${{ inputs.target_branch }}' not found." |
44 | 40 | exit 1 |
45 | 41 | fi |
46 | 42 |
|
47 | | - # Find version.json and emit its absolute path |
48 | 43 | - name: Locate version.json |
49 | 44 | id: locate_version |
50 | 45 | shell: bash |
51 | 46 | run: | |
52 | | - # Search Git-tracked files first … |
53 | 47 | REL_PATH=$(git ls-files --full-name '*version.json' | head -n1) |
54 | | -
|
55 | | - # … fall back to a filesystem search for untracked files (optional) |
56 | 48 | if [[ -z "$REL_PATH" ]]; then |
57 | 49 | REL_PATH=$(find . -type f -name version.json | head -n1 | sed 's|^\./||') |
58 | 50 | fi |
59 | | -
|
60 | 51 | if [[ -z "$REL_PATH" ]]; then |
61 | 52 | echo "::error::version.json not found on branch '${{ inputs.target_branch }}'." |
62 | | - tree -L 2 -C || true |
63 | 53 | exit 1 |
64 | 54 | fi |
| 55 | + echo "file=$GITHUB_WORKSPACE/$REL_PATH" >> "$GITHUB_OUTPUT" |
65 | 56 |
|
66 | | - ABS_PATH="$GITHUB_WORKSPACE/$REL_PATH" |
67 | | - echo "Found version.json at: $ABS_PATH" |
68 | | -
|
69 | | - # Pass the path to other jobs |
70 | | - echo "file=$ABS_PATH" >> "$GITHUB_OUTPUT" |
71 | | -
|
72 | | - prepare: |
| 57 | + prepare-main: |
73 | 58 | needs: validate_branch |
| 59 | + if: ${{ inputs.target_branch == 'main' || inputs.target_branch == 'master' }} |
74 | 60 | uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_prepare_release.yml@main |
75 | 61 | with: |
76 | 62 | target_branch: ${{ inputs.target_branch }} |
77 | 63 | increment: ${{ inputs.increment }} |
78 | 64 | version_file_path: ${{ needs.validate_branch.outputs.version_json_path }} |
79 | 65 | secrets: inherit |
80 | 66 |
|
81 | | - publish: |
82 | | - needs: prepare |
| 67 | + prepare-develop: |
| 68 | + needs: validate_branch |
| 69 | + if: ${{ inputs.target_branch == 'develop' }} |
| 70 | + uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_prepare_release.yml@develop |
| 71 | + with: |
| 72 | + target_branch: ${{ inputs.target_branch }} |
| 73 | + increment: ${{ inputs.increment }} |
| 74 | + version_file_path: ${{ needs.validate_branch.outputs.version_json_path }} |
| 75 | + secrets: inherit |
| 76 | + |
| 77 | + publish-main: |
| 78 | + needs: prepare-main |
| 79 | + if: ${{ inputs.target_branch == 'main' || inputs.target_branch == 'master' }} |
83 | 80 | uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_dotnet_pack.yml@main |
84 | 81 | with: |
85 | | - checkout_ref: ${{ needs.prepare.outputs.release_branch }} |
86 | | - build_configuration: ${{ inputs.target_branch == 'develop' && 'Develop' || 'Release' }} |
| 82 | + checkout_ref: ${{ needs.prepare-main.outputs.release_branch }} |
| 83 | + build_configuration: Release |
| 84 | + push_after_pack: true |
| 85 | + force_dev_prerelease: false |
| 86 | + secrets: |
| 87 | + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 88 | + |
| 89 | + publish-develop: |
| 90 | + needs: prepare-develop |
| 91 | + if: ${{ inputs.target_branch == 'develop' }} |
| 92 | + uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_dotnet_pack.yml@develop |
| 93 | + with: |
| 94 | + checkout_ref: ${{ needs.prepare-develop.outputs.release_branch }} |
| 95 | + build_configuration: Develop |
87 | 96 | push_after_pack: true |
88 | | - force_dev_prerelease: ${{ inputs.target_branch == 'develop' }} |
| 97 | + force_dev_prerelease: true |
89 | 98 | secrets: |
90 | 99 | NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
0 commit comments