-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (81 loc) · 2.59 KB
/
publish.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
name: Publish
on:
workflow_dispatch:
push:
tags:
- v[0-9]+.*
permissions:
contents: write
jobs:
publish:
name: Publish to crates.io and GitHub
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test
- name: Check version matches tag
if: github.event_name == 'push'
run: |
PKG_VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "Version mismatch: Tag version ($TAG_VERSION) doesn't match Cargo.toml version ($PKG_VERSION)"
exit 1
fi
- name: Build release binaries
run: |
cargo build --release
mkdir -p release-artifacts
cp target/release/termv release-artifacts/termv-${{ github.ref_name }}-linux-x86_64
- name: Publish to crates.io
if: github.event_name == 'push'
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
release-artifacts/*
build-macos:
name: Build macOS binary
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --release
mkdir -p release-artifacts
cp target/release/termv release-artifacts/termv-${{ github.ref_name }}-darwin-x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-binary
path: release-artifacts/*
build-windows:
name: Build Windows binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --release
mkdir release-artifacts
copy target\release\termv.exe release-artifacts\termv-${{ github.ref_name }}-windows-x86_64.exe
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-binary
path: release-artifacts\*