Skip to content

Commit 8b1789d

Browse files
Jayllyzanonrig
authored andcommitted
ci: add github release workflow
1 parent 448694a commit 8b1789d

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish-tag:
7+
description: 'The tag of the version to publish'
8+
required: true
9+
type: string
10+
11+
concurrency:
12+
group: release
13+
14+
env:
15+
RUST_BACKTRACE: 1
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
test-release:
20+
name: Check & Test release
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- os: windows-latest
26+
- os: ubuntu-latest
27+
- os: macos-latest
28+
- os: ubuntu-latest
29+
env:
30+
CARGO_BUILD_TARGET: wasm32-wasi
31+
CARGO_TARGET_WASM32_WASI_RUNNER: /home/runner/.wasmtime/bin/wasmtime --dir=.
32+
runs-on: ${{ matrix.os }}
33+
if: github.ref == 'refs/heads/main'
34+
env: ${{ matrix.env || fromJSON('{}') }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
with:
38+
persist-credentials: false
39+
40+
- name: Install Wasm deps
41+
if: matrix.env.CARGO_BUILD_TARGET == 'wasm32-wasi'
42+
run: |
43+
rustup target add wasm32-wasi
44+
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk_20.0_amd64.deb
45+
sudo dpkg --install wasi-sdk_20.0_amd64.deb
46+
curl https://wasmtime.dev/install.sh -sSf | bash
47+
48+
- uses: Swatinem/rust-cache@v2
49+
with:
50+
shared-key: release
51+
save-if: ${{ github.ref_name == 'main' }}
52+
53+
- run: rustup show
54+
55+
- name: Install cargo-hack
56+
uses: taiki-e/install-action@cargo-hack
57+
58+
- name: Clippy
59+
run: cargo hack clippy --feature-powerset -- -D warnings
60+
61+
- name: Test
62+
run: cargo hack test --feature-powerset
63+
64+
- name: Check Documentation
65+
env:
66+
RUSTDOCFLAGS: '-D warnings'
67+
run: cargo hack doc --feature-powerset
68+
69+
- name: Check semver
70+
if: matrix.os == 'ubuntu-latest'
71+
uses: obi1kenobi/cargo-semver-checks-action@v2
72+
73+
publish-release:
74+
name: Publish release
75+
needs: test-release
76+
runs-on: ubuntu-latest
77+
if: github.ref == 'refs/heads/main'
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
with:
82+
persist-credentials: true
83+
84+
- name: Install Rust toolchain
85+
uses: moonrepo/setup-rust@v1
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Publish to crates.io
90+
run: cargo publish
91+
env:
92+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
93+
94+
- name: Tag the version
95+
env:
96+
GIT_TAG: ${{ inputs.publish-tag }}
97+
run: |
98+
git tag "${GIT_TAG}"
99+
git push origin "${GIT_TAG}"
100+
101+
- name: Create github release
102+
uses: taiki-e/create-gh-release-action@v1
103+
with:
104+
branch: main
105+
ref: refs/tags/"${GIT_TAG}"
106+
env:
107+
GIT_TAG: ${{ inputs.publish-tag }}
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)