-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (130 loc) · 4.24 KB
/
release.yml
File metadata and controls
154 lines (130 loc) · 4.24 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
name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
artifact: chisel-linux-x86_64
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
artifact: chisel-linux-x86_64-musl
use_musl: true
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
artifact: chisel-linux-arm64
use_cross: true
- target: x86_64-apple-darwin
runner: macos-latest
artifact: chisel-macos-x86_64
- target: aarch64-apple-darwin
runner: macos-latest
artifact: chisel-macos-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: release-${{ matrix.target }}-
- name: Install musl tools
if: matrix.use_musl
run: sudo apt-get install -y musl-tools
- name: Install cross
if: matrix.use_cross
uses: taiki-e/install-action@cross
- name: Build (cross)
if: matrix.use_cross
run: cross build --release -p chisel --target ${{ matrix.target }}
- name: Build (cargo)
if: ${{ !matrix.use_cross }}
run: cargo build --release -p chisel --target ${{ matrix.target }}
- name: Rename artifact
run: cp target/${{ matrix.target }}/release/chisel ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
retention-days: 1
bundle:
name: Bundle .mcpb (${{ matrix.artifact }})
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- artifact: chisel-macos-arm64
- artifact: chisel-macos-x86_64
- artifact: chisel-linux-x86_64
- artifact: chisel-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Extract version
id: version
run: |
VERSION=$(grep '^version' chisel/Cargo.toml | head -1 | sed 's/.*= *"//' | sed 's/".*//')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Download binary (${{ matrix.artifact }})
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: artifacts
- name: Pack .mcpb
run: |
ARTIFACT="${{ matrix.artifact }}"
STAGE="bundle/_stage"
# No version prefix — keeps the /releases/latest/download/ URL stable.
MCPB_NAME="${ARTIFACT}.mcpb"
mkdir -p "$STAGE/server"
cp bundle/manifest.json "$STAGE/manifest.json"
[ -f chisel.jpeg ] && cp chisel.jpeg "$STAGE/icon.png"
cp "artifacts/$ARTIFACT" "$STAGE/server/chisel"
chmod +x "$STAGE/server/chisel"
(cd "$STAGE" && zip -r "$GITHUB_WORKSPACE/bundle/${MCPB_NAME}" . -x "*.DS_Store")
rm -rf "$STAGE"
- name: Upload .mcpb artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}-mcpb
path: bundle/${{ matrix.artifact }}.mcpb
retention-days: 7
release:
name: Publish release
runs-on: ubuntu-latest
needs: [build, bundle]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true