Release #2
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., 1.4.0)' | |
| required: true | |
| type: string | |
| env: | |
| SCHEME: "SNOMED Lookup" | |
| DESTINATION: "platform=macOS" | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: macos-14 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Validate version format | |
| run: | | |
| if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: Version must be in format X.Y.Z (e.g., 1.4.0)" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check for existing tag | |
| run: | | |
| if git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then | |
| echo "Error: Tag v${{ inputs.version }} already exists" | |
| exit 1 | |
| fi | |
| - name: Update CHANGELOG.md | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| DATE=$(date +%Y-%m) | |
| # Check if there are unreleased changes | |
| if ! grep -q "## \[Unreleased\]" CHANGELOG.md; then | |
| echo "Error: No [Unreleased] section found in CHANGELOG.md" | |
| exit 1 | |
| fi | |
| # Check if there's content under Unreleased | |
| UNRELEASED_CONTENT=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | sed '1d;$d') | |
| if [ -z "$(echo "$UNRELEASED_CONTENT" | grep -v '^[[:space:]]*$')" ]; then | |
| echo "Error: No changes documented under [Unreleased] section" | |
| exit 1 | |
| fi | |
| # Replace [Unreleased] with new version, keeping Unreleased section for future | |
| sed -i '' "s/## \[Unreleased\]/## [Unreleased]\n\n## [$VERSION] - $DATE/" CHANGELOG.md | |
| echo "Updated CHANGELOG.md for version $VERSION" | |
| cat CHANGELOG.md | head -50 | |
| - name: Update Xcode project version | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| # Update MARKETING_VERSION in project.pbxproj for the main app target | |
| # This updates all occurrences which covers Debug and Release configurations | |
| sed -i '' "s/MARKETING_VERSION = [0-9]*\.[0-9]*\.[0-9]*;/MARKETING_VERSION = $VERSION;/g" \ | |
| "SNOMED Lookup.xcodeproj/project.pbxproj" | |
| echo "Updated Xcode project version to $VERSION" | |
| grep "MARKETING_VERSION" "SNOMED Lookup.xcodeproj/project.pbxproj" | |
| - name: Extract release notes | |
| id: release_notes | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| # Extract the section for this version (between ## [version] and next ## [) | |
| NOTES=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '1d;$d') | |
| # Write to file for GitHub release | |
| echo "$NOTES" > release_notes.md | |
| echo "Release notes:" | |
| cat release_notes.md | |
| - name: Commit release changes | |
| run: | | |
| git add CHANGELOG.md "SNOMED Lookup.xcodeproj/project.pbxproj" | |
| git commit -m "release: v${{ inputs.version }}" | |
| - name: Create and push tag | |
| run: | | |
| git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}" | |
| git push origin main | |
| git push origin "v${{ inputs.version }}" | |
| - name: Select Xcode | |
| run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer | |
| - name: Build Release | |
| run: | | |
| xcodebuild build \ | |
| -scheme "$SCHEME" \ | |
| -destination "$DESTINATION" \ | |
| -configuration Release \ | |
| -derivedDataPath build \ | |
| CODE_SIGN_IDENTITY="-" \ | |
| CODE_SIGNING_REQUIRED=NO \ | |
| ENABLE_HARDENED_RUNTIME=NO \ | |
| ENABLE_APP_SANDBOX=NO | |
| - name: Create artifact | |
| run: | | |
| mkdir -p artifact | |
| cp -R "build/Build/Products/Release/SNOMED Lookup.app" artifact/ | |
| cd artifact | |
| zip -r "SNOMED-Lookup-v${{ inputs.version }}-macOS.zip" "SNOMED Lookup.app" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ inputs.version }} | |
| name: SNOMED Lookup v${{ inputs.version }} | |
| body_path: release_notes.md | |
| files: artifact/SNOMED-Lookup-v${{ inputs.version }}-macOS.zip | |
| draft: false | |
| prerelease: false |