-
Notifications
You must be signed in to change notification settings - Fork 555
154 lines (148 loc) · 5.12 KB
/
cli_cd.yaml
File metadata and controls
154 lines (148 loc) · 5.12 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
144
145
146
147
148
149
150
151
152
153
154
on:
workflow_dispatch:
inputs:
channel:
description: "Release channel"
required: true
type: choice
options:
- nightly
- stable
concurrency:
group: ${{ github.workflow }}-${{ inputs.channel }}
cancel-in-progress: true
jobs:
compute-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- run: git fetch --tags --force
- uses: ./.github/actions/doxxer_install
- id: version
run: |
if [[ "${{ inputs.channel }}" == "nightly" ]]; then
LATEST_TAG=$(git tag -l 'cli_v*' --sort=-creatordate | head -n1)
if [[ "$LATEST_TAG" == *"-nightly"* ]]; then
VERSION=$(doxxer --config doxxer.cli.toml next prerelease)
else
VERSION=$(doxxer --config doxxer.cli.toml next pre-patch)
fi
else
VERSION=$(doxxer --config doxxer.cli.toml next patch)
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Computed version: $VERSION"
build:
needs: compute-version
strategy:
fail-fast: true
matrix:
include:
- target: aarch64-apple-darwin
runner: depot-macos-15
platform: macos
- target: x86_64-unknown-linux-gnu
runner: depot-ubuntu-24.04-8
platform: linux-x86_64
- target: aarch64-unknown-linux-gnu
runner: depot-ubuntu-24.04-arm-8
platform: linux-aarch64
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev libpulse-dev pkg-config
- uses: ./.github/actions/rust_install
with:
platform: ${{ matrix.platform }}
- if: matrix.platform == 'macos'
run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
- run: cargo build --release -p cli --target ${{ matrix.target }}
- run: |
BIN="target/${{ matrix.target }}/release/char"
if [[ "${{ runner.os }}" == "macOS" ]]; then
strip -x "$BIN"
else
strip "$BIN"
fi
ARCHIVE="char-${{ needs.compute-version.outputs.version }}-${{ matrix.target }}.tar.xz"
tar -cJf "$ARCHIVE" -C "target/${{ matrix.target }}/release" char
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: char-${{ matrix.target }}
path: ${{ env.ARCHIVE }}
retention-days: 3
create-tag:
needs: [compute-version, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: cli_v${{ needs.compute-version.outputs.version }}
tag_prefix: ""
release:
needs: [compute-version, build, create-tag]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- id: checksums
uses: ./.github/actions/generate_checksums
with:
files: |
artifacts/char-${{ needs.compute-version.outputs.version }}-aarch64-apple-darwin.tar.xz
artifacts/char-${{ needs.compute-version.outputs.version }}-x86_64-unknown-linux-gnu.tar.xz
artifacts/char-${{ needs.compute-version.outputs.version }}-aarch64-unknown-linux-gnu.tar.xz
- id: artifacts
run: |
TARBALLS=$(ls artifacts/*.tar.xz | tr '\n' ',')
CHECKSUMS=$(ls artifacts/*.sha256 | tr '\n' ',')
echo "list=${TARBALLS}${CHECKSUMS}" >> $GITHUB_OUTPUT
- uses: ncipollo/release-action@v1
with:
tag: cli_v${{ needs.compute-version.outputs.version }}
name: char v${{ needs.compute-version.outputs.version }}
prerelease: ${{ inputs.channel == 'nightly' }}
artifacts: ${{ steps.artifacts.outputs.list }}
publish-npm:
needs: [compute-version, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- run: |
cd apps/cli/npm
VERSION="${{ needs.compute-version.outputs.version }}"
NPM_TAG="${{ inputs.channel == 'nightly' && 'nightly' || 'latest' }}"
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '$VERSION';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
npm publish --access public --tag "$NPM_TAG"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}