Skip to content

Commit d0a1236

Browse files
committed
refactor: 統合されたリリースワークフローの実装
- release-workflow.ymlに全ての機能を統合 - needsによる依存関係で効率的な実行順序を実現 - sleep削除により無駄な待機時間を排除 - Homebrewフォーミュラ更新の直接コミット化 - 不要なワークフローファイル削除 (release.yml, update-homebrew.yml) これにより真のワンクリックリリースを実現
1 parent 61f25e5 commit d0a1236

File tree

3 files changed

+95
-142
lines changed

3 files changed

+95
-142
lines changed

.github/workflows/release-workflow.yml

Lines changed: 95 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ permissions:
1818
pull-requests: write
1919

2020
jobs:
21-
release:
21+
version-bump:
2222
runs-on: ubuntu-latest
23-
23+
outputs:
24+
new_version: ${{ steps.new_version.outputs.new }}
25+
2426
steps:
2527
- name: Checkout
2628
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -43,20 +45,12 @@ jobs:
4345
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
4446
echo "Current version: $CURRENT_VERSION"
4547
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-
5348
- name: Calculate new version
5449
id: new_version
5550
run: |
5651
CURRENT_VERSION="${{ steps.current_version.outputs.current }}"
57-
RELEASE_TYPE="${{ steps.release_type.outputs.type }}"
52+
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
5853
NEW_VERSION=$(semver -i $RELEASE_TYPE $CURRENT_VERSION)
59-
6054
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
6155
echo "New version: $NEW_VERSION"
6256
@@ -73,18 +67,103 @@ jobs:
7367
git config --local user.name "GitHub Action"
7468
git add Cargo.toml
7569
git commit -m "chore: release v$NEW_VERSION"
70+
7671
- name: Create and push tag
7772
run: |
7873
NEW_VERSION="${{ steps.new_version.outputs.new }}"
7974
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
8075
git push origin main
8176
git push origin "v$NEW_VERSION"
8277
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
8497
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
89128
env:
90129
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

.github/workflows/release.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/update-homebrew.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)