|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Version to release (e.g., 1.2.0)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + release: |
| 19 | + name: Build and Release |
| 20 | + runs-on: macos-14 |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Setup Xcode |
| 29 | + uses: maxim-lobanov/setup-xcode@v1 |
| 30 | + with: |
| 31 | + xcode-version: latest-stable |
| 32 | + |
| 33 | + - name: Determine version |
| 34 | + id: version |
| 35 | + run: | |
| 36 | + if [ -n "${{ github.event.inputs.version }}" ]; then |
| 37 | + VERSION="${{ github.event.inputs.version }}" |
| 38 | + else |
| 39 | + VERSION="${GITHUB_REF#refs/tags/v}" |
| 40 | + fi |
| 41 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 42 | + echo "📦 Building version: $VERSION" |
| 43 | +
|
| 44 | + - name: Update Info.plist version |
| 45 | + run: | |
| 46 | + /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${{ steps.version.outputs.version }}" Info.plist |
| 47 | + /usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${{ steps.version.outputs.version }}" Info.plist |
| 48 | +
|
| 49 | + - name: Build release |
| 50 | + run: make release |
| 51 | + |
| 52 | + - name: Calculate SHA256 |
| 53 | + id: sha |
| 54 | + run: | |
| 55 | + SHA256=$(shasum -a 256 dist/VPNBypass-${{ steps.version.outputs.version }}.dmg | awk '{print $1}') |
| 56 | + echo "sha256=$SHA256" >> $GITHUB_OUTPUT |
| 57 | + echo "📝 SHA256: $SHA256" |
| 58 | +
|
| 59 | + - name: Generate changelog |
| 60 | + id: changelog |
| 61 | + run: | |
| 62 | + VERSION="v${{ steps.version.outputs.version }}" |
| 63 | + PREV_TAG=$(git tag -l "v*" --sort=-version:refname | sed -n '2p') |
| 64 | + |
| 65 | + if [ -z "$PREV_TAG" ]; then |
| 66 | + PREV_TAG=$(git rev-list --max-parents=0 HEAD) |
| 67 | + fi |
| 68 | + |
| 69 | + echo "📝 Generating changelog from $PREV_TAG to $VERSION" |
| 70 | + |
| 71 | + { |
| 72 | + echo "## What's Changed" |
| 73 | + echo "" |
| 74 | + |
| 75 | + # Features |
| 76 | + FEATURES=$(git log $PREV_TAG..HEAD --pretty=format:"- %s" --grep="^feat" 2>/dev/null || true) |
| 77 | + if [ -n "$FEATURES" ]; then |
| 78 | + echo "### ✨ Features" |
| 79 | + echo "$FEATURES" | head -20 |
| 80 | + echo "" |
| 81 | + fi |
| 82 | + |
| 83 | + # Fixes |
| 84 | + FIXES=$(git log $PREV_TAG..HEAD --pretty=format:"- %s" --grep="^fix" 2>/dev/null || true) |
| 85 | + if [ -n "$FIXES" ]; then |
| 86 | + echo "### 🐛 Bug Fixes" |
| 87 | + echo "$FIXES" | head -20 |
| 88 | + echo "" |
| 89 | + fi |
| 90 | + |
| 91 | + # Other changes |
| 92 | + OTHERS=$(git log $PREV_TAG..HEAD --pretty=format:"- %s" --invert-grep --grep="^feat" --invert-grep --grep="^fix" 2>/dev/null | head -10 || true) |
| 93 | + if [ -n "$OTHERS" ]; then |
| 94 | + echo "### 🔧 Other Changes" |
| 95 | + echo "$OTHERS" |
| 96 | + echo "" |
| 97 | + fi |
| 98 | + |
| 99 | + echo "---" |
| 100 | + echo "" |
| 101 | + echo "## Installation" |
| 102 | + echo "" |
| 103 | + echo "### Homebrew (recommended)" |
| 104 | + echo '```bash' |
| 105 | + echo "brew tap GeiserX/vpn-bypass" |
| 106 | + echo "brew install --cask vpn-bypass" |
| 107 | + echo '```' |
| 108 | + echo "" |
| 109 | + echo "### Manual Download" |
| 110 | + echo "Download \`VPNBypass-${{ steps.version.outputs.version }}.dmg\` from the assets below." |
| 111 | + echo "" |
| 112 | + echo "---" |
| 113 | + echo "" |
| 114 | + echo "**SHA256:** \`${{ steps.sha.outputs.sha256 }}\`" |
| 115 | + echo "" |
| 116 | + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREV_TAG...$VERSION" |
| 117 | + } > changelog.md |
| 118 | + |
| 119 | + cat changelog.md |
| 120 | +
|
| 121 | + - name: Create GitHub Release |
| 122 | + uses: softprops/action-gh-release@v2 |
| 123 | + with: |
| 124 | + tag_name: v${{ steps.version.outputs.version }} |
| 125 | + name: "VPNBypass v${{ steps.version.outputs.version }}" |
| 126 | + body_path: changelog.md |
| 127 | + draft: false |
| 128 | + prerelease: false |
| 129 | + files: | |
| 130 | + dist/VPNBypass-${{ steps.version.outputs.version }}.dmg |
| 131 | +
|
| 132 | + - name: Update Homebrew Cask |
| 133 | + env: |
| 134 | + HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 135 | + run: | |
| 136 | + if [ -z "$HOMEBREW_TAP_TOKEN" ]; then |
| 137 | + echo "⚠️ HOMEBREW_TAP_TOKEN not set, skipping Homebrew update" |
| 138 | + echo "To enable automatic Homebrew updates, add a PAT with repo scope as HOMEBREW_TAP_TOKEN secret" |
| 139 | + exit 0 |
| 140 | + fi |
| 141 | + |
| 142 | + VERSION="${{ steps.version.outputs.version }}" |
| 143 | + SHA256="${{ steps.sha.outputs.sha256 }}" |
| 144 | + |
| 145 | + # Clone homebrew tap |
| 146 | + git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/GeiserX/homebrew-vpn-bypass.git" homebrew-tap |
| 147 | + cd homebrew-tap |
| 148 | + |
| 149 | + # Update cask file |
| 150 | + sed -i '' "s/version \".*\"/version \"$VERSION\"/" Casks/vpn-bypass.rb |
| 151 | + sed -i '' "s/sha256 \".*\"/sha256 \"$SHA256\"/" Casks/vpn-bypass.rb |
| 152 | + |
| 153 | + # Commit and push |
| 154 | + git config user.name "github-actions[bot]" |
| 155 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 156 | + git add Casks/vpn-bypass.rb |
| 157 | + git commit -m "Update vpn-bypass to v$VERSION" |
| 158 | + git push |
| 159 | + |
| 160 | + echo "✅ Homebrew cask updated to v$VERSION" |
0 commit comments