forked from drewzemke/tongo
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (110 loc) · 4.02 KB
/
Copy pathcd.yml
File metadata and controls
132 lines (110 loc) · 4.02 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
name: CD
on:
push:
tags:
- "v*.*.*"
jobs:
publish:
name: Build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: tongo
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: tongo
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
dependencies: "gcc"
artifact_name: tongo
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross_arch: true
artifact_name: tongo
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross_arch: true
artifact_name: tongo
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: tongo.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Linux Dependencies
if: matrix.dependencies
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.dependencies }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --locked --release --target ${{ matrix.target }}
use-cross: ${{ matrix.cross_arch }}
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
case ${{ matrix.target }} in
*-pc-windows-*)
7z -y a tongo-${{ matrix.target }}.zip tongo.exe
sha256sum tongo-${{ matrix.target }}.zip > tongo-${{ matrix.target }}.sha256
;;
*)
tar czvf tongo-${{ matrix.target }}.tar.gz tongo
shasum -a 256 tongo-${{ matrix.target }}.tar.gz > tongo-${{ matrix.target }}.sha256
;;
esac;
- name: Release
uses: softprops/action-gh-release@v2
with:
files: target/${{ matrix.target }}/release/tongo-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
name: Update Homebrew formula
runs-on: ubuntu-latest
needs: publish
steps:
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Wait for release assets
run: sleep 10
- name: Download SHA256 checksums
run: |
curl -sL "https://github.com/drewzemke/tongo/releases/download/${{ github.ref_name }}/tongo-aarch64-apple-darwin.sha256" -o arm64.sha256
curl -sL "https://github.com/drewzemke/tongo/releases/download/${{ github.ref_name }}/tongo-x86_64-apple-darwin.sha256" -o x86_64.sha256
echo "ARM64_SHA256=$(cut -d ' ' -f 1 arm64.sha256)" >> "$GITHUB_ENV"
echo "X86_64_SHA256=$(cut -d ' ' -f 1 x86_64.sha256)" >> "$GITHUB_ENV"
- name: Checkout homebrew-tap repo
uses: actions/checkout@v4
with:
repository: drewzemke/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
run: |
sed -i 's/version "[^"]*"/version "${{ steps.version.outputs.version }}"/' Formula/tongo.rb
sed -i '/on_arm do/{n;n;s/sha256 "[^"]*"/sha256 "${{ env.ARM64_SHA256 }}"/}' Formula/tongo.rb
sed -i '/on_intel do/{n;n;s/sha256 "[^"]*"/sha256 "${{ env.X86_64_SHA256 }}"/}' Formula/tongo.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/tongo.rb
git commit -m "chore(tongo): update to ${{ steps.version.outputs.version }}"
git push