Skip to content

Commit 4213f5c

Browse files
committed
Release action
1 parent b651907 commit 4213f5c

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/release.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# .github/workflows/deploy.yml
2+
name: Release
3+
4+
on:
5+
push:
6+
# branches:
7+
# - 'main'
8+
tags:
9+
- "v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z0-9]+.[0-9]+)?"
10+
workflow_dispatch:
11+
repository_dispatch:
12+
types: [ webhook ]
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
build-and-upload:
19+
name: Build and upload
20+
runs-on: ${{ matrix.os }}
21+
22+
strategy:
23+
matrix:
24+
# You can add more, for any target you'd like!
25+
include:
26+
- build: linux x86
27+
os: ubuntu-latest
28+
target: x86_64-unknown-linux-musl
29+
- build: linux arm64
30+
os: ubuntu-latest
31+
target: aarch64-unknown-linux-musl
32+
33+
- build: macos x86
34+
os: macos-latest
35+
target: x86_64-apple-darwin
36+
- build: macos arm64
37+
os: macos-latest
38+
target: aarch64-apple-darwin
39+
40+
- build: win x86
41+
os: windows-latest
42+
target: x86_64-pc-windows-msvc
43+
# - build: win arm64
44+
# os: windows-latest
45+
# target: aarch64-pc-windows-msvc
46+
# error: failed to run custom build command for `mozjpeg-sys v*`
47+
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Get the release version from the tag
53+
shell: bash
54+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
55+
56+
- name: Install Rust
57+
# Or @nightly if you want
58+
uses: dtolnay/rust-toolchain@stable
59+
# Arguments to pass in
60+
with:
61+
# Make Rust compile to our target (defined in the matrix)
62+
targets: ${{ matrix.target }}
63+
64+
- name: Build
65+
uses: clechasseur/rs-cargo@v2
66+
with:
67+
use-cross: true
68+
command: build
69+
args: --verbose --release --target ${{ matrix.target }}
70+
71+
- name: Build archive
72+
shell: bash
73+
run: |
74+
# Replace with the name of your binary
75+
binary_name="caesiumclt"
76+
77+
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
78+
mkdir "$dirname"
79+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
80+
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
81+
else
82+
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
83+
fi
84+
85+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
86+
7z a "$dirname.zip" "$dirname"
87+
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
88+
else
89+
tar -czf "$dirname.tar.gz" "$dirname"
90+
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
91+
fi
92+
93+
# https://github.com/softprops/action-gh-release?tab=readme-ov-file#-customizing
94+
- name: Release
95+
uses: softprops/action-gh-release@v2
96+
with:
97+
files: |
98+
${{ env.ASSET }}
99+
# body_path: ''
100+
body: "|Arch|Filename|\n
101+
|:--: |:--:|\n
102+
|MacOS ARM| caesiumclt-v*-aarch64-apple-darwin.tar.gz|\n
103+
|MacOS x86_64| caesiumclt-v*-x86_64-apple-darwin.tar.gz|\n
104+
|Linux ARM| caesiumclt-v*-aarch64-unknown-linux-musl.tar.gz|\n
105+
|Linux x86_64| caesiumclt-v*-x86_64-unknown-linux-musl.tar.gz|\n
106+
|Windows x86_64| caesiumclt-v*-x86_64-pc-windows-msvc.zip|\n"
107+
108+
- name: Upload Artifact 🚀
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: ${{ env.ASSET }}
112+
path: ${{ env.ASSET }}
113+
114+
- name: Upload binaries to release ☕
115+
uses: svenstaro/upload-release-action@v2
116+
with:
117+
repo_token: ${{ secrets.GITHUB_TOKEN }}
118+
file: ${{ env.ASSET }}
119+
asset_name: ${{ env.ASSET }}
120+
tag: ${{ github.ref }}
121+
overwrite: true
122+
body: "Generated by Github Actions"

0 commit comments

Comments
 (0)