Repository navigation
143 lines (122 loc) · 4.16 KB
/
Copy pathdeploy.yml
File metadata and controls
143 lines (122 loc) · 4.16 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: release
on:
push:
tags:
- "*.*.*"
permissions:
contents: read
jobs:
create-windows-binaries:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Build git-statuses
run: cargo build --release --locked
- name: Build package
id: package
shell: bash
run: |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
ARCHIVE_FILE="git-statuses-${VERSION}-x86_64-pc-windows-msvc.zip"
7z a "$ARCHIVE_FILE" ./target/release/git-statuses.exe
echo "file=$ARCHIVE_FILE" >> "$GITHUB_OUTPUT"
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ steps.package.outputs.file }}
path: ${{ steps.package.outputs.file }}
create-unix-binaries:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# macOS needs nothing extra: libgit2 uses the system TLS there, and OpenSSL is only
# vendored into the Linux build.
- name: Install musl-tools and musl OpenSSL
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools curl pkg-config libssl-dev
echo "PKG_CONFIG_ALLOW_CROSS=1" >> "$GITHUB_ENV"
- name: Build git-statuses
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Strip binary
run: strip target/${{ matrix.target }}/release/git-statuses
- name: Build package
id: package
run: |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
TAR_FILE="git-statuses-${VERSION}-${{ matrix.target }}"
tar -czvf "$TAR_FILE.tar.gz" -C target/${{ matrix.target }}/release git-statuses
echo "name=$TAR_FILE" >> "$GITHUB_OUTPUT"
echo "file=$TAR_FILE.tar.gz" >> "$GITHUB_OUTPUT"
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.file }}
deploy:
needs: [create-windows-binaries, create-unix-binaries]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: ./binaries
merge-multiple: true
- name: Create a release
uses: softprops/action-gh-release@v3
with:
name: v${{ github.ref_name }}
files: |
./binaries/*.zip
./binaries/*.tar.gz
homebrew:
name: Update the Homebrew formula
needs: deploy
# Prereleases never become the formula's version.
if: ${{ !contains(github.ref_name, '-') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: scripts/homebrew_formula.sh
sparse-checkout-cone-mode: false
- name: Download the release archives
uses: actions/download-artifact@v8
with:
path: release
merge-multiple: true
- uses: actions/checkout@v7
with:
repository: bircni/homebrew-tap
ssh-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
path: tap
- name: Commit the formula
run: |
mkdir -p tap/Formula
bash scripts/homebrew_formula.sh "$GITHUB_REF_NAME" release > tap/Formula/git-statuses.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/git-statuses.rb
if ! git diff --cached --quiet; then
git commit -m "git-statuses $GITHUB_REF_NAME"
git push
fi