Release #75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g. 0.1.3)' | |
| required: true | |
| type: string | |
| jobs: | |
| release: | |
| runs-on: macos-15 | |
| permissions: | |
| contents: write | |
| outputs: | |
| tag: ${{ steps.version.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Resolve version and tag | |
| id: version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| VERSION="${VERSION#v}" # strip leading 'v' if provided | |
| else | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| - name: Setup Swift | |
| uses: SwiftyLab/setup-swift@latest | |
| with: | |
| swift-version: "6.2" | |
| - name: Update version in source | |
| run: | | |
| sed -i '' "s/let ascVersion = \".*\"/let ascVersion = \"${{ steps.version.outputs.version }}\"/" Sources/ASCCommand/Version.swift | |
| grep ascVersion Sources/ASCCommand/Version.swift | |
| - name: Create release directory | |
| run: mkdir -p release | |
| - name: Build arm64 | |
| run: | | |
| swift build -c release --arch arm64 --disable-sandbox | |
| strip -rSTx .build/arm64-apple-macosx/release/asc | |
| cp .build/arm64-apple-macosx/release/asc release/asc_${{ steps.version.outputs.tag }}_macOS_arm64 | |
| - name: Build x86_64 | |
| run: | | |
| swift build -c release --arch x86_64 --disable-sandbox | |
| strip -rSTx .build/x86_64-apple-macosx/release/asc | |
| cp .build/x86_64-apple-macosx/release/asc release/asc_${{ steps.version.outputs.tag }}_macOS_x86_64 | |
| - name: Create universal binary | |
| run: | | |
| lipo -create -output release/asc_${{ steps.version.outputs.tag }}_macOS_universal \ | |
| release/asc_${{ steps.version.outputs.tag }}_macOS_arm64 \ | |
| release/asc_${{ steps.version.outputs.tag }}_macOS_x86_64 | |
| - name: Create checksums | |
| run: | | |
| cd release | |
| shasum -a 256 * > asc_${{ steps.version.outputs.tag }}_checksums.txt | |
| - name: Extract release notes from CHANGELOG | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| NOTES=$(./scripts/extract-changelog.sh "$VERSION" 2>/dev/null || echo "") | |
| if [ -z "$NOTES" ]; then | |
| NOTES="Bug fixes and improvements." | |
| echo "::warning::No CHANGELOG entry found for v$VERSION, using default message" | |
| echo "used_fallback=true" >> $GITHUB_OUTPUT | |
| fi | |
| echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
| echo "$NOTES" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: asc ${{ steps.version.outputs.tag }} | |
| body: ${{ env.RELEASE_NOTES }} | |
| files: release/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Promote CHANGELOG | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| ./scripts/promote-changelog.sh "$VERSION" "$(date +%Y-%m-%d)" | |
| # Sync fallback release notes into the newly promoted [VERSION] section | |
| if [ "${{ steps.changelog.outputs.used_fallback }}" = "true" ]; then | |
| awk -v ver="$VERSION" ' | |
| $0 ~ ("^## \\[" ver "\\] - ") { in_ver=1; print; next } | |
| in_ver && /[^[:space:]]/ && !/^---$/ { has_content=1 } | |
| in_ver && /^---$/ { | |
| if (!has_content) { | |
| print "### Changed" | |
| print "- Bug fixes and improvements." | |
| print "" | |
| } | |
| in_ver=0 | |
| } | |
| in_ver && /^## \[/ { in_ver=0 } | |
| { print } | |
| ' CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGELOG.md | |
| git diff --cached --quiet \ | |
| && echo "No CHANGELOG changes to commit" \ | |
| || git commit -m "chore(changelog): promote [Unreleased] to v${{ steps.version.outputs.version }}" | |
| git push origin HEAD:main | |
| update-tap: | |
| needs: release | |
| uses: ./.github/workflows/update-homebrew-tap.yml | |
| with: | |
| version: ${{ needs.release.outputs.tag }} | |
| secrets: inherit |