-
Notifications
You must be signed in to change notification settings - Fork 561
159 lines (152 loc) · 5.22 KB
/
cli_cd.yaml
File metadata and controls
159 lines (152 loc) · 5.22 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
155
156
157
158
159
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
runs-on: depot-macos-15
strategy:
matrix:
target:
- aarch64-apple-darwin
- x86_64-apple-darwin
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust_install
with:
platform: macos
- run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
- run: cargo build --release -p cli --target ${{ matrix.target }}
env:
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
APP_VERSION: ${{ needs.compute-version.outputs.version }}
- run: |
BIN="target/${{ matrix.target }}/release/char"
strip -x "$BIN"
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
publish-npm:
needs: [compute-version, build]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.14.0"
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm@11.5.1
- run: |
node -v
npm -v
- 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 --tag "$NPM_TAG"
create-tag:
needs: [compute-version, publish-npm]
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
with:
fetch-depth: 0
fetch-tags: true
- run: git fetch --tags --force
- 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-apple-darwin.tar.xz
- id: artifacts
run: |
LIST=$(ls artifacts/*.tar.xz artifacts/*.sha256 | paste -sd,)
echo "list=$LIST" >> $GITHUB_OUTPUT
- id: release-body
env:
VERSION: ${{ needs.compute-version.outputs.version }}
run: |
CURRENT_TAG="cli_v$VERSION"
PREV_TAG=$(git tag -l 'cli_v*' --sort=-v:refname | grep -v "^$CURRENT_TAG$" | head -n1)
if [[ -n "$PREV_TAG" ]]; then
echo "value=https://github.com/${{ github.repository }}/compare/$PREV_TAG...$CURRENT_TAG" >> "$GITHUB_OUTPUT"
else
echo "value=https://github.com/${{ github.repository }}/commits/$CURRENT_TAG" >> "$GITHUB_OUTPUT"
fi
- uses: ncipollo/release-action@v1
with:
tag: cli_v${{ needs.compute-version.outputs.version }}
name: char_v${{ needs.compute-version.outputs.version }}
body: ${{ steps.release-body.outputs.value }}
prerelease: ${{ inputs.channel == 'nightly' }}
artifacts: ${{ steps.artifacts.outputs.list }}