Skip to content

Commit 46879bc

Browse files
authored
Merge pull request #20 from twio142/master
ci: release with universal build
2 parents 0d8501c + 6b9a6de commit 46879bc

File tree

1 file changed

+32
-47
lines changed

1 file changed

+32
-47
lines changed

.github/workflows/homebrew.yml

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,57 @@ on:
33
push:
44
# Sequence of patterns matched against refs/tags
55
tags:
6-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
77

88
jobs:
99
homebrew:
1010
name: "Create homebrew release"
1111
runs-on: macos-latest
1212
steps:
13-
- name: Get tag
14-
id: push
15-
run: |
16-
echo ::set-output name=name::${GITHUB_REF#refs/*/}
17-
echo ::set-output name=branch::${GITHUB_REF#refs/heads/}
18-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
19-
echo ::set-output name=tag_unprefixed::${GITHUB_REF#refs/tags/v}
13+
- uses: actions/checkout@v4
2014

21-
- uses: actions/checkout@v2
22-
- name: Install latest nightly
23-
uses: actions-rs/toolchain@v1
24-
with:
25-
toolchain: nightly
26-
override: true
15+
- uses: dtolnay/rust-toolchain@stable
2716

28-
- name: Run cargo build --release
29-
uses: actions-rs/cargo@v1
30-
with:
31-
command: build
32-
args: --release
17+
- name: Build
18+
run: |
19+
rustup target add x86_64-apple-darwin
20+
rustup target add aarch64-apple-darwin
21+
cargo build --release --target x86_64-apple-darwin
22+
cargo build --release --target aarch64-apple-darwin
3323
34-
- name: Homebrew archive and shasum
24+
- name: Create universal binary
3525
id: archive
3626
run: |
37-
cd target/release
38-
tar -czf dark-notify-${{ steps.push.outputs.tag }}.tar.gz dark-notify
39-
SUM=$(shasum -a 256 dark-notify-${{ steps.push.outputs.tag }}.tar.gz | awk '{print $1}')
40-
echo "::set-output name=shasum::$SUM"
27+
lipo -create -output ./dark-notify target/x86_64-apple-darwin/release/dark-notify target/aarch64-apple-darwin/release/dark-notify
28+
tar -czvf dark-notify.tar.gz ./dark-notify
4129
42-
- name: Create Release
43-
id: create_release
44-
uses: actions/create-release@v1
45-
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
with:
48-
tag_name: ${{ steps.push.outputs.tag }}
49-
release_name: Release ${{ steps.push.outputs.tag }}
50-
draft: false
51-
prerelease: false
30+
SUM=$(shasum -a 256 dark-notify.tar.gz | awk '{print $1}')
31+
echo "shasum=$SUM" >> $GITHUB_OUTPUT
5232
53-
- name: Upload Release Asset
54-
id: upload_release_asset
55-
uses: actions/upload-release-asset@v1
56-
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Release
34+
id: release
35+
uses: softprops/action-gh-release@v2
5836
with:
59-
upload_url: ${{ steps.create_release.outputs.upload_url }}
60-
asset_path: target/release/dark-notify-${{ steps.push.outputs.tag }}.tar.gz
61-
asset_name: dark-notify-${{ steps.push.outputs.tag }}.tar.gz
62-
asset_content_type: application/gzip
37+
tag_name: ${{ github.ref_name }}
38+
name: Release ${{ github.ref_name }}
39+
files: |
40+
dark-notify.tar.gz
41+
fail_on_unmatched_files: true
42+
43+
- name: Get asset URL
44+
id: get_url
45+
run: |
46+
URL="${{ fromJson(steps.release.outputs.assets)[0].browser_download_url }}"
47+
echo "url=$URL" >> $GITHUB_OUTPUT
6348
6449
- name: Update Homebrew formula
6550
env:
6651
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.BREW_TOKEN }}
52+
VERSION: ${{ github.ref_name }}
6753
run: |
6854
brew tap cormacrelf/tap
6955
brew bump-formula-pr -f --no-browse --no-audit \
70-
--version='${{ steps.push.outputs.tag_unprefixed }}' \
71-
--sha256='${{ steps.archive.outputs.shasum }}' \
72-
--url='${{ steps.upload_release_asset.outputs.browser_download_url }}' \
56+
--version="${VERSION#v}" \
57+
--sha256="${{ steps.archive.outputs.shasum }}" \
58+
--url="${{ steps.get_url.outputs.url }}" \
7359
cormacrelf/tap/dark-notify
74-

0 commit comments

Comments
 (0)