-
Notifications
You must be signed in to change notification settings - Fork 2
76 lines (71 loc) · 2.49 KB
/
Copy pathrelease.yml
File metadata and controls
76 lines (71 loc) · 2.49 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
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: xmaster
asset_name: xmaster-x86_64-linux
- os: macos-latest
target: aarch64-apple-darwin
artifact: xmaster
asset_name: xmaster-aarch64-darwin
- os: macos-latest
target: x86_64-apple-darwin
artifact: xmaster
asset_name: xmaster-x86_64-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: xmaster.exe
asset_name: xmaster-x86_64-windows.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- run: cargo build --release --locked --target ${{ matrix.target }}
- name: Rename artifact
shell: bash
run: cp target/${{ matrix.target }}/release/${{ matrix.artifact }} ${{ matrix.asset_name }}
- name: Upload to release
uses: softprops/action-gh-release@v3.0.0
with:
files: ${{ matrix.asset_name }}
# Publish the new version to crates.io. Idempotent: skips if already published.
# Requires the CARGO_REGISTRY_TOKEN secret; warns and skips if it is absent.
# Homebrew is bumped separately by the self-polling workflow in paperfoot/homebrew-tap.
publish-crate:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
set -euo pipefail
if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
echo "::warning::CARGO_REGISTRY_TOKEN not set — skipping crates.io publish."
echo "Add it with: gh secret set CARGO_REGISTRY_TOKEN -R paperfoot/xmaster-cli"
exit 0
fi
VERSION=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"(.*)".*/\1/')
if curl -fsSL "https://index.crates.io/xm/as/xmaster" | grep -q "\"vers\":\"${VERSION}\""; then
echo "xmaster ${VERSION} already on crates.io — skipping."
else
cargo publish --locked
fi