|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Triggers on any tag starting with 'v' (e.g., v1.0.0) |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Create Release |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v3 |
| 14 | + |
| 15 | + - name: Get version from tag |
| 16 | + id: get_version |
| 17 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV |
| 18 | + |
| 19 | + - name: Extract release notes |
| 20 | + id: extract_notes |
| 21 | + run: | |
| 22 | + # Extract changelog section for this version if available |
| 23 | + if [ -f CHANGELOG.md ]; then |
| 24 | + NOTES=$(awk -v ver=$VERSION '/^## \['$VERSION'\]/{flag=1;next}/^## \[/{flag=0}flag' CHANGELOG.md) |
| 25 | + if [ -z "$NOTES" ]; then |
| 26 | + NOTES="Release version $VERSION" |
| 27 | + fi |
| 28 | + else |
| 29 | + NOTES="Release version $VERSION" |
| 30 | + fi |
| 31 | + echo "NOTES<<EOF" >> $GITHUB_ENV |
| 32 | + echo "$NOTES" >> $GITHUB_ENV |
| 33 | + echo "EOF" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: Update formula version |
| 36 | + run: | |
| 37 | + sed -i 's/version "[0-9]\+\.[0-9]\+\.[0-9]\+"/version "'$VERSION'"/' Formula/tctl.rb |
| 38 | + |
| 39 | + # Get new checksums for the binaries |
| 40 | + INTEL_URL="https://binaries.dl.tetrate.io/public/raw/versions/darwin-amd64-$VERSION/tctl" |
| 41 | + ARM_URL="https://binaries.dl.tetrate.io/public/raw/versions/darwin-arm64-$VERSION/tctl" |
| 42 | + |
| 43 | + mkdir -p /tmp/tctl-checksums |
| 44 | + curl -s -L -o /tmp/tctl-checksums/tctl-intel "$INTEL_URL" |
| 45 | + curl -s -L -o /tmp/tctl-checksums/tctl-arm "$ARM_URL" |
| 46 | + |
| 47 | + INTEL_SHA=$(shasum -a 256 /tmp/tctl-checksums/tctl-intel | cut -d ' ' -f 1) |
| 48 | + ARM_SHA=$(shasum -a 256 /tmp/tctl-checksums/tctl-arm | cut -d ' ' -f 1) |
| 49 | + |
| 50 | + # Update the SHA256 checksums in the formula |
| 51 | + sed -i 's/sha256 "[a-f0-9]\{64\}" # Intel/sha256 "'$INTEL_SHA'" # Intel/' Formula/tctl.rb |
| 52 | + sed -i 's/sha256 "[a-f0-9]\{64\}" # ARM/sha256 "'$ARM_SHA'" # ARM/' Formula/tctl.rb |
| 53 | + |
| 54 | + - name: Commit formula updates |
| 55 | + run: | |
| 56 | + git config --local user.email "action@github.com" |
| 57 | + git config --local user.name "GitHub Action" |
| 58 | + git commit -am "Update formula for version $VERSION" |
| 59 | + git push |
| 60 | + |
| 61 | + - name: Create Release |
| 62 | + id: create_release |
| 63 | + uses: softprops/action-gh-release@v1 |
| 64 | + with: |
| 65 | + name: Release ${{ env.VERSION }} |
| 66 | + body: ${{ env.NOTES }} |
| 67 | + draft: false |
| 68 | + prerelease: false |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments