|
12 | 12 | type: string |
13 | 13 |
|
14 | 14 | jobs: |
15 | | - update-release: |
16 | | - runs-on: ubuntu-latest |
| 15 | + call-external: |
| 16 | + uses: holtjma/shared_github_workflows/.github/workflows/update-release.yml@286c4ec0efbe7aac72a7149cfbd2a00f57457881 |
17 | 17 | permissions: |
18 | 18 | contents: write |
19 | | - steps: |
20 | | - - name: Checkout code |
21 | | - uses: actions/checkout@v4 |
22 | | - |
23 | | - - name: Extract version from tag |
24 | | - id: extract_version |
25 | | - run: | |
26 | | - # Handle both automatic tag pushes and manual workflow dispatch |
27 | | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
28 | | - # Manual trigger - use input parameter |
29 | | - TAG="${{ github.event.inputs.tag }}" |
30 | | - VERSION=${TAG#v} |
31 | | - else |
32 | | - # Automatic trigger - extract from git tag |
33 | | - TAG=${GITHUB_REF#refs/tags/} |
34 | | - VERSION=${TAG#v} |
35 | | - fi |
36 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
37 | | - echo "tag=$TAG" >> $GITHUB_OUTPUT |
38 | | -
|
39 | | - - name: Extract changelog section |
40 | | - id: changelog |
41 | | - run: | |
42 | | - # Find the changelog section for this version |
43 | | - if grep -q "^# v${{ steps.extract_version.outputs.version }}$" CHANGELOG.md; then |
44 | | - # Extract from the version header to the next version header or end of file |
45 | | - awk ' |
46 | | - /^# v${{ steps.extract_version.outputs.version }}$/ { |
47 | | - in_section = 1; |
48 | | - next |
49 | | - } |
50 | | - /^# v[0-9]+\.[0-9]+\.[0-9]+$/ && in_section { |
51 | | - exit |
52 | | - } |
53 | | - in_section { |
54 | | - print |
55 | | - } |
56 | | - ' CHANGELOG.md > release_body.txt |
57 | | -
|
58 | | - echo "" >> release_body.txt |
59 | | - echo "---" >> release_body.txt |
60 | | - echo "" >> release_body.txt |
61 | | - echo "This release was automatically updated from tag ${{ steps.extract_version.outputs.tag }}." >> release_body.txt |
62 | | - else |
63 | | - echo "No changelog found for version ${{ steps.extract_version.outputs.version }}" > release_body.txt |
64 | | - fi |
65 | | -
|
66 | | - - name: Get Release ID |
67 | | - id: get_release |
68 | | - run: | |
69 | | - # Get the release ID for this tag |
70 | | - RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/${{ steps.extract_version.outputs.tag }} --jq '.id') |
71 | | - echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT |
72 | | - env: |
73 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
74 | | - |
75 | | - - name: Update Release |
76 | | - run: | |
77 | | - # Update the existing release with new changelog content |
78 | | - gh api repos/${{ github.repository }}/releases/${{ steps.get_release.outputs.release_id }} \ |
79 | | - --method PATCH \ |
80 | | - --field body=@release_body.txt |
81 | | - env: |
82 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + secrets: |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments