-
Notifications
You must be signed in to change notification settings - Fork 81
180 lines (150 loc) · 4.57 KB
/
release.yml
File metadata and controls
180 lines (150 loc) · 4.57 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release CLI
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.artifact }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest # Apple Silicon (arm64)
artifact: muapi-darwin-arm64
- os: ubuntu-22.04 # Linux x86_64
artifact: muapi-linux-x86_64
- os: ubuntu-24.04-arm # Linux arm64
artifact: muapi-linux-arm64
- os: windows-latest # Windows x86_64
artifact: muapi-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install CLI + PyInstaller
run: |
pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Build binary (Unix)
if: runner.os != 'Windows'
run: |
pyinstaller \
--onefile \
--name muapi \
--distpath ./dist \
cli_entry.py
- name: Build binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
pyinstaller `
--onefile `
--name muapi `
--distpath ./dist `
cli_entry.py
- name: Rename artifact (Unix)
if: runner.os != 'Windows'
run: mv dist/muapi dist/${{ matrix.artifact }}
- name: Rename artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Move-Item dist\muapi.exe dist\${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
retention-days: 1
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifact directories
run: |
mkdir -p release_assets
find artifacts -type f -exec cp {} release_assets/ \;
chmod +x release_assets/muapi-darwin-* release_assets/muapi-linux-* 2>/dev/null || true
ls -lh release_assets/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: muapi-cli ${{ github.ref_name }}
body: |
## muapi-cli ${{ github.ref_name }}
### Install via npm
```bash
npm install -g muapi-cli
```
### Install via pip
```bash
pip install muapi-cli
```
### Manual binary download
| Platform | Binary |
|---|---|
| macOS Apple Silicon | `muapi-darwin-arm64` |
| Linux x86_64 | `muapi-linux-x86_64` |
| Linux ARM64 | `muapi-linux-arm64` |
| Windows x86_64 | `muapi-windows-x86_64.exe` |
draft: false
prerelease: false
files: release_assets/*
publish-npm:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
jq --arg v "$VERSION" '.version = $v' npm/package.json > /tmp/pkg.json
mv /tmp/pkg.json npm/package.json
echo "Publishing npm version $VERSION"
- name: Publish
run: npm publish --access public
working-directory: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
echo "Publishing PyPI version $VERSION"
- name: Build
run: |
pip install hatch
hatch build
- name: Publish
run: |
pip install twine
twine upload dist/* --non-interactive
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}