|
16 | 16 | type: string |
17 | 17 |
|
18 | 18 | jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - os: linux |
| 25 | + arch: amd64 |
| 26 | + - os: linux |
| 27 | + arch: arm64 |
| 28 | + - os: darwin |
| 29 | + arch: amd64 |
| 30 | + - os: darwin |
| 31 | + arch: arm64 |
| 32 | + - os: windows |
| 33 | + arch: amd64 |
| 34 | + ext: .exe |
| 35 | + - os: windows |
| 36 | + arch: arm64 |
| 37 | + ext: .exe |
| 38 | + |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v6 |
| 42 | + with: |
| 43 | + ref: ${{ github.event.inputs.tag || github.ref }} |
| 44 | + fetch-depth: 0 # Fetch full history (needed for release notes generation) |
| 45 | + fetch-tags: true # Ensure tags are fetched (needed for release notes generation) |
| 46 | + |
| 47 | + - name: Set up runner environment |
| 48 | + uses: ./.github/actions/prep-runner |
| 49 | + |
| 50 | + - name: Build Go binary for ${{ matrix.os }}-${{ matrix.arch }} |
| 51 | + uses: ./.github/actions/build-go-binaries |
| 52 | + with: |
| 53 | + binary-name: utils |
| 54 | + os: ${{ matrix.os }} |
| 55 | + arch: ${{ matrix.arch }} |
| 56 | + ext: ${{ matrix.ext || '' }} |
| 57 | + |
19 | 58 | release: |
| 59 | + needs: build |
20 | 60 | runs-on: ubuntu-latest |
21 | 61 | permissions: |
22 | 62 | contents: write |
|
28 | 68 | fetch-depth: 0 # Fetch full history (needed for release notes generation) |
29 | 69 | fetch-tags: true # Ensure tags are fetched (needed for release notes generation) |
30 | 70 |
|
| 71 | + - name: Download all artifacts |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + path: artifacts |
| 75 | + merge-multiple: true |
| 76 | + |
| 77 | + - name: Prepare release artifacts |
| 78 | + run: | |
| 79 | + mkdir -p release |
| 80 | + find artifacts -type f -exec mv {} release/ \; |
| 81 | + ls -la release/ |
| 82 | +
|
| 83 | + - name: Create release notes |
| 84 | + id: release_notes |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ github.token }} |
| 87 | + run: | |
| 88 | + gh ext install devx-cafe/gh-tt |
| 89 | + mkdir -p .tmp |
| 90 | + gh tt semver note --filename .tmp/RELEASENOTES.md |
| 91 | + echo "Generating release notes..." |
| 92 | + cat .tmp/RELEASENOTES.md >> $GITHUB_STEP_SUMMARY |
| 93 | +
|
| 94 | + # Nice to have a version.txt in the release assets, so we know what commit and tag the release was built from |
| 95 | + - name: version.txt |
| 96 | + run: | |
| 97 | + mkdir -p release |
| 98 | + echo "Build from ${{ github.repository }}" > release/version.txt |
| 99 | + echo "Tag: ${{ github.ref_name }}" >> release/version.txt |
| 100 | + echo "Commit: ${{ github.sha }}" >> release/version.txt |
| 101 | +
|
| 102 | + - name: Determine release type |
| 103 | + id: release_type |
| 104 | + run: | |
| 105 | + TAG="${{ github.event.inputs.tag || github.ref_name }}" |
| 106 | + # Check if tag contains prerelease markers (- or +) after SemVer core |
| 107 | + # Lines 5-6 in trigger: [0-9]+.[0-9]+.[0-9]+* and [a-zA-Z]+[0-9]+.[0-9]+.[0-9]+* |
| 108 | + if [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([-]) ]]; then |
| 109 | + echo "is_prerelease=true" >> $GITHUB_OUTPUT |
| 110 | + echo "is_draft=false" >> $GITHUB_OUTPUT |
| 111 | + echo "Release type: PRERELEASE" |
| 112 | + elif [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([+]) ]]; then |
| 113 | + echo "is_prerelease=false" >> $GITHUB_OUTPUT |
| 114 | + echo "is_draft=true" >> $GITHUB_OUTPUT |
| 115 | + echo "Release type: DRAFT" |
| 116 | + else |
| 117 | + echo "is_prerelease=false" >> $GITHUB_OUTPUT |
| 118 | + echo "is_draft=false" >> $GITHUB_OUTPUT |
| 119 | + echo "Release type: STABLE" |
| 120 | + fi |
| 121 | +
|
| 122 | + - name: Create Release |
| 123 | + uses: softprops/action-gh-release@v1 |
| 124 | + with: |
| 125 | + tag_name: ${{ github.event.inputs.tag || github.ref_name }} |
| 126 | + files: release/* |
| 127 | + body_path: .tmp/RELEASENOTES.md |
| 128 | + draft: ${{ steps.release_type.outputs.is_draft }} |
| 129 | + prerelease: ${{ steps.release_type.outputs.is_prerelease }} |
| 130 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +--- |
| 135 | + release: |
| 136 | + runs-on: ubuntu-latest |
| 137 | + needs: build |
| 138 | + |
| 139 | + steps: |
| 140 | + |
31 | 141 | - name: Determine release type |
32 | 142 | id: release_type |
33 | 143 | run: | |
|
0 commit comments