-
Notifications
You must be signed in to change notification settings - Fork 20
148 lines (144 loc) · 4.98 KB
/
cd.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
name: CD
# yamllint disable-line rule:truthy
on:
release:
types: [published]
workflow_dispatch:
inputs:
build:
description: "Run build-and-upload-artifacts"
required: true
type: boolean
tag:
description: "Release tag"
required: true
type: string
permissions:
contents: write
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build-and-upload-artifacts:
name: Build & Upload Artifacts (${{ matrix.target }})
if: startsWith(github.event.release.name, 'tetanes') || inputs.build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
# TODO: windows aarch64
# - target: aarch64-pc-windows-msvc
# os: windows-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# TODO: aarch64 linux having trouble with docker in CI
# - target: aarch64-unknown-linux-gnu
# os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: wasm32-unknown-unknown
os: ubuntu-latest
defaults:
run:
shell: bash
outputs:
release_tag: ${{ steps.upload.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
# wasm32-unknown-unknown doesn't need additional toolchains and rustup
# target is managed by build-artifacts already
#
# Windows/macOS just run `rustup add` since the CI runners support cross-compiling
# Linux relies on `cross`
- if: ${{ !startsWith(matrix.os, 'ubuntu') }}
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- if: startsWith(matrix.os, 'ubuntu')
uses: baptiste0928/cargo-install@v3
with:
crate: cross
git: https://github.com/cross-rs/cross
commit: 19be834
- uses: taiki-e/install-action@v2
with:
tool: cargo-make
# Build `.deb`
- if: startsWith(matrix.os, 'ubuntu')
uses: taiki-e/install-action@v2
with:
tool: cargo-deb
# Build `.msi`
- if: startsWith(matrix.os, 'windows')
uses: taiki-e/install-action@v2
with:
tool: cargo-wix
# Build `.wasm`
- if: startsWith(matrix.target, 'wasm32')
uses: taiki-e/install-action@v2
with:
tool: trunk
# Install linux dependencies
- if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt update
sudo apt install -y libudev-dev libasound2-dev libssl-dev libfuse2
# Windows/macOS/wasm32/ubuntu x86_64 can all build/cross build normally
- if: startsWith(matrix.os, 'macos') || startsWith(matrix.target, 'x86_64') || startsWith(matrix.target, 'wasm32')
run: |
cargo make build-artifacts -- --target ${{ matrix.target }}
# ubuntu aarch64 requires cross building
- if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.target, 'aarch64')
run: |
export CROSS_CONTAINER_IN_CONTAINER=true
cargo make build-artifacts -- --target ${{ matrix.target }} --cross
- uses: actions/upload-artifact@v4
name: "Upload artifacts"
with:
name: ${{ matrix.target }}-artifacts
path: dist/
- id: upload
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload ${{ github.event.release.tag_name || inputs.tag }} dist/* --clobber
echo "release_tag=${{ github.event.release.tag_name || inputs.tag }}" >> "$GITHUB_OUTPUT"
update-homebrew-formula:
name: Update Homebrew Formula
if: startsWith(github.event.release.name, 'tetanes') || inputs.build
needs: build-and-upload-artifacts
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ needs.build-and-upload-artifacts.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
with:
repository: "lukexor/homebrew-formulae"
- id: commit
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release -R lukexor/tetanes download $RELEASE_TAG --pattern '*-apple-darwin.tar.gz*'
x86_64_SHA=$(cat *x86_64*txt | awk '{ print $1 }')
aarch64_SHA=$(cat *aarch64*txt | awk '{ print $1 }')
VERSION=${RELEASE_TAG#"tetanes-v"}
cat tetanes.rb.tmpl | \
sed "s/%VERSION%/${VERSION}/g" | \
sed "s/%x86_64_SHA%/${x86_64_SHA}/g" | \
sed "s/%aarch64_SHA%/${aarch64_SHA}/g" \
> Casks/tetanes.rb
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: "*.rb"
commit_message: Version Bump v${{ steps.commit.outputs.version }}