@@ -18,9 +18,11 @@ permissions:
18
18
pull-requests : write
19
19
20
20
jobs :
21
- release :
21
+ version-bump :
22
22
runs-on : ubuntu-latest
23
-
23
+ outputs :
24
+ new_version : ${{ steps.new_version.outputs.new }}
25
+
24
26
steps :
25
27
- name : Checkout
26
28
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -43,20 +45,12 @@ jobs:
43
45
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
44
46
echo "Current version: $CURRENT_VERSION"
45
47
46
- - name : Set release type
47
- id : release_type
48
- run : |
49
- RELEASE_TYPE="${{ github.event.inputs.release_type }}"
50
- echo "type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
51
- echo "Release type: $RELEASE_TYPE"
52
-
53
48
- name : Calculate new version
54
49
id : new_version
55
50
run : |
56
51
CURRENT_VERSION="${{ steps.current_version.outputs.current }}"
57
- RELEASE_TYPE="${{ steps.release_type.outputs.type }}"
52
+ RELEASE_TYPE="${{ github.event.inputs.release_type }}"
58
53
NEW_VERSION=$(semver -i $RELEASE_TYPE $CURRENT_VERSION)
59
-
60
54
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
61
55
echo "New version: $NEW_VERSION"
62
56
@@ -73,18 +67,103 @@ jobs:
73
67
git config --local user.name "GitHub Action"
74
68
git add Cargo.toml
75
69
git commit -m "chore: release v$NEW_VERSION"
70
+
76
71
- name : Create and push tag
77
72
run : |
78
73
NEW_VERSION="${{ steps.new_version.outputs.new }}"
79
74
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
80
75
git push origin main
81
76
git push origin "v$NEW_VERSION"
82
77
83
- - name : Trigger Homebrew update
78
+ release-binaries :
79
+ needs : version-bump
80
+ runs-on : macos-latest
81
+
82
+ steps :
83
+ - name : Checkout
84
+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
85
+ with :
86
+ ref : " v${{ needs.version-bump.outputs.new_version }}"
87
+
88
+ - name : Install Rust
89
+ uses : actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1.13.0
90
+ with :
91
+ toolchain : stable
92
+
93
+ - name : Build release binary
94
+ run : cargo build --release
95
+
96
+ - name : Create release archive
84
97
run : |
85
- NEW_VERSION="${{ steps.new_version.outputs.new }}"
86
- # Wait a moment for the release workflow to complete
87
- sleep 60
88
- gh workflow run "Update Homebrew Formula" --field tag="v$NEW_VERSION"
98
+ mkdir -p dist
99
+ cp target/release/confirm-pam dist/
100
+ cd dist
101
+ tar -czf confirm-pam-macos-amd64.tar.gz confirm-pam
102
+ shasum -a 256 confirm-pam-macos-amd64.tar.gz > confirm-pam-macos-amd64.tar.gz.sha256
103
+
104
+ - name : Create Release
105
+ uses : softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
106
+ with :
107
+ tag_name : " v${{ needs.version-bump.outputs.new_version }}"
108
+ files : |
109
+ dist/confirm-pam-macos-amd64.tar.gz
110
+ dist/confirm-pam-macos-amd64.tar.gz.sha256
111
+ draft : false
112
+ prerelease : false
113
+ env :
114
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
115
+
116
+ update-homebrew :
117
+ needs : [version-bump, release-binaries]
118
+ runs-on : ubuntu-latest
119
+
120
+ steps :
121
+ - name : Checkout
122
+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
123
+ with :
124
+ fetch-depth : 0
125
+
126
+ - name : Get release info
127
+ id : release
89
128
env :
90
129
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
130
+ run : |
131
+ TAG="v${{ needs.version-bump.outputs.new_version }}"
132
+ echo "tag=$TAG" >> $GITHUB_OUTPUT
133
+
134
+ # Construct download URL directly
135
+ DOWNLOAD_URL="https://github.com/azu/confirm-pam/releases/download/$TAG/confirm-pam-macos-amd64.tar.gz"
136
+ echo "Download URL: $DOWNLOAD_URL"
137
+
138
+ # Download and calculate SHA256
139
+ curl -sL "$DOWNLOAD_URL" -o temp.tar.gz
140
+ if [ ! -f temp.tar.gz ]; then
141
+ echo "Failed to download $DOWNLOAD_URL"
142
+ exit 1
143
+ fi
144
+
145
+ SHA256=$(shasum -a 256 temp.tar.gz | cut -d' ' -f1)
146
+ echo "SHA256: $SHA256"
147
+ rm temp.tar.gz
148
+
149
+ echo "asset_url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT
150
+ echo "sha256=$SHA256" >> $GITHUB_OUTPUT
151
+ echo "version=${{ needs.version-bump.outputs.new_version }}" >> $GITHUB_OUTPUT
152
+
153
+ - name : Update Formula
154
+ run : |
155
+ # Update the formula file
156
+ sed -i "s|url \".*\"|url \"${{ steps.release.outputs.asset_url }}\"|" Formula/confirm-pam.rb
157
+ sed -i "s|sha256 \".*\"|sha256 \"${{ steps.release.outputs.sha256 }}\"|" Formula/confirm-pam.rb
158
+
159
+ # Show the changes
160
+ echo "Updated Formula:"
161
+ cat Formula/confirm-pam.rb
162
+
163
+ - name : Commit and push formula update
164
+ run : |
165
+ git config --local user.email "action@github.com"
166
+ git config --local user.name "GitHub Action"
167
+ git add Formula/confirm-pam.rb
168
+ git commit -m "chore: update Homebrew formula to ${{ steps.release.outputs.tag }}"
169
+ git push origin main
0 commit comments