-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (119 loc) · 4.16 KB
/
Copy pathci.yml
File metadata and controls
137 lines (119 loc) · 4.16 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
# =============================================================================
# CI & Release
# =============================================================================
# Runs on tag push to build release binaries and create GitHub release.
# =============================================================================
name: CI
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # v1.0.0
- "v[0-9]+.[0-9]+.[0-9]+-*" # v1.0.0-beta.1, v1.0.0-rc.1
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
BINARY_NAME: termstack
jobs:
# ---------------------------------------------------------------------------
# Build Binaries
# ---------------------------------------------------------------------------
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS Intel
- os: macos-latest
target: x86_64-apple-darwin
name: macos-amd64
artifact: termstack-macos-amd64
# macOS Apple Silicon
- os: macos-latest
target: aarch64-apple-darwin
name: macos-arm64
artifact: termstack-macos-arm64
# Linux x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux-amd64
artifact: termstack-linux-amd64
# Linux ARM64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
name: linux-arm64
artifact: termstack-linux-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" Cargo.toml
rm -f Cargo.toml.bak
echo "Set version to ${VERSION}"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build (native)
if: matrix.target != 'aarch64-unknown-linux-gnu'
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: cross build --release --target ${{ matrix.target }}
- name: Package binary
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../${{ matrix.artifact }}.tar.gz ${{ env.BINARY_NAME }}
cd ../../..
- name: Generate checksum
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
shasum -a 256 ${{ matrix.artifact }}.tar.gz > ${{ matrix.artifact }}.sha256
else
sha256sum ${{ matrix.artifact }}.tar.gz > ${{ matrix.artifact }}.sha256
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
${{ matrix.artifact }}.tar.gz
${{ matrix.artifact }}.sha256
# ---------------------------------------------------------------------------
# Create Release
# ---------------------------------------------------------------------------
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -type f \( -name "*.tar.gz" -o -name "*.sha256" \) -exec mv {} release/ \;
ls -la release/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: release/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}