-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (101 loc) · 3.45 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build-and-upload:
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rust-src
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build release binary
env:
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}
run: cargo build --verbose --release --target ${{ matrix.target }}
- name: Package release assets
shell: bash
run: |
cd target/${{ matrix.target }}/release
# Define binary name with extension if windows
BIN_NAME=glimpse
if [ "${{ matrix.os }}" = "windows-latest" ]; then
BIN_NAME=glimpse.exe
fi
# Create archive name
ARCHIVE_NAME=glimpse-${{ github.ref_name }}-${{ matrix.target }}
# Create dist directory with required files
mkdir -p $ARCHIVE_NAME
cp $BIN_NAME $ARCHIVE_NAME/
cp ../../../readme.md $ARCHIVE_NAME/
cp ../../../LICENSE $ARCHIVE_NAME/
# Create archive based on OS
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a -tzip "${ARCHIVE_NAME}.zip" $ARCHIVE_NAME
else
tar -czf "${ARCHIVE_NAME}.tar.gz" $ARCHIVE_NAME
fi
- name: Upload release artifacts
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/glimpse-*.tar.gz
target/${{ matrix.target }}/release/glimpse-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
needs: build-and-upload
runs-on: ubuntu-latest
steps:
- name: Checkout homebrew tap
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/homebrew-glimpse
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
run: |
# Get tarball URL and SHA
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz"
SHA256=$(curl -L $TARBALL_URL | shasum -a 256 | cut -d ' ' -f 1)
# Update formula version and hash
sed -i "s|url.*|url \"$TARBALL_URL\"|" Formula/glimpse.rb
sed -i "s|sha256.*|sha256 \"$SHA256\"|" Formula/glimpse.rb
- name: Commit and push changes
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add Formula/glimpse.rb
git commit -m "chore: update to ${{ github.ref_name }}"
git push