Skip to content

Commit d550b34

Browse files
authored
Merge pull request #33 from chainbound/feat/actions
feat(ci): release Github workflows
2 parents 6a72f00 + 8f1c811 commit d550b34

File tree

10 files changed

+276
-6
lines changed

10 files changed

+276
-6
lines changed

.github/workflows/audit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Audit
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/Cargo.toml"
7+
- "**/Cargo.lock"
8+
9+
jobs:
10+
security_audit:
11+
runs-on: ubuntu-latest
12+
permissions: write-all
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions-rs/audit-check@v1
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Cross Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
extract-version:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Export Crate Package Version
12+
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT
13+
id: export
14+
outputs:
15+
VERSION: ${{ steps.export.outputs.VERSION }}
16+
17+
build:
18+
name: build release
19+
strategy:
20+
matrix:
21+
arch:
22+
[
23+
aarch64-unknown-linux-gnu,
24+
x86_64-unknown-linux-gnu,
25+
x86_64-apple-darwin,
26+
aarch64-apple-darwin,
27+
x86_64-pc-windows-gnu,
28+
]
29+
include:
30+
- arch: aarch64-unknown-linux-gnu
31+
platform: ubuntu-20.04
32+
profile: maxperf
33+
- arch: x86_64-unknown-linux-gnu
34+
platform: ubuntu-20.04
35+
profile: maxperf
36+
- arch: x86_64-apple-darwin
37+
platform: macos-latest
38+
profile: maxperf
39+
- arch: aarch64-apple-darwin
40+
platform: macos-latest
41+
profile: maxperf
42+
- arch: x86_64-pc-windows-gnu
43+
platform: ubuntu-20.04
44+
profile: maxperf
45+
46+
runs-on: ${{ matrix.platform }}
47+
needs: extract-version
48+
env:
49+
VERSION: ${{ needs.extract-version.outputs.VERSION }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
- run: rustup update stable
53+
- run: rustup target add ${{ matrix.arch }}
54+
- uses: Swatinem/rust-cache@v2
55+
with:
56+
cache-on-failure: true
57+
- name: Apple M1 setup
58+
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
59+
run: |
60+
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
61+
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
62+
- name: Build for ${{ matrix.arch }}
63+
run: |
64+
cargo install cross
65+
env PROFILE=${{ matrix.profile }} make build-${{ matrix.arch }}
66+
- name: Move cross-compiled binary
67+
if: matrix.arch != 'x86_64-pc-windows-gnu'
68+
run: |
69+
mkdir artifacts
70+
mv target/${{ matrix.arch }}/${{ matrix.profile }}/* ./artifacts
71+
- name: Create artifacts
72+
run: tar --directory=artifacts -czf release-${{ env.VERSION }}-${{ matrix.arch }}.tar.gz $(ls -U artifacts/ | head -1)
73+
shell: bash
74+
75+
release:
76+
name: Release on Github
77+
runs-on: ubuntu-latest
78+
permissions:
79+
contents: write
80+
needs: [build, extract-version]
81+
env:
82+
VERSION: ${{ needs.extract-version.outputs.VERSION }}
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: ncipollo/release-action@v1
86+
with:
87+
artifacts: "artifacts/*"
88+
tag: v${{ env.VERSION }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Github Release
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["CI"]
7+
branches: [main]
8+
types:
9+
- completed
10+
11+
jobs:
12+
extract-crate-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Export Crate Package Version
17+
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT
18+
id: export_crate_version
19+
outputs:
20+
VERSION: ${{ steps.export_crate_version.outputs.VERSION }}
21+
22+
release:
23+
name: Release on Github
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
needs: [extract-crate-version]
28+
env:
29+
VERSION: ${{ needs.extract-crate-version.outputs.VERSION }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- run: cargo build --release
33+
- name: Generate the Release Tarball
34+
run: tar --directory=target/release -cf release.tar.gz $(ls -U target/release/ | head -1)
35+
- uses: ncipollo/release-action@v1
36+
with:
37+
artifacts: "release.tar.gz"
38+
tag: v${{ env.VERSION }}

.github/workflows/manual-tag.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Manual Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The version to release. Should match the version in `Cargo.toml`. For example, 0.1.20"
8+
required: true
9+
10+
jobs:
11+
tag:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
timeout-minutes: 20
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: anothrNick/github-tag-action@master
19+
env:
20+
CUSTOM_TAG: v${{ inputs.version }}
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["CI"]
7+
branches: [main]
8+
types:
9+
- completed
10+
11+
jobs:
12+
publish:
13+
name: Publish Crate to Crates.io
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
profile: minimal
20+
toolchain: stable
21+
override: true
22+
- uses: baptiste0928/cargo-install@v2
23+
with:
24+
crate: cargo-release
25+
- run: CARGO_REGISTRY_TOKEN=${CRATES_TOKEN} cargo release --execute --no-confirm --no-push --no-tag
26+
env:
27+
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

.github/workflows/tag.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tag
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
branches: [main]
7+
types:
8+
- completed
9+
10+
jobs:
11+
extract-crate-version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Export Crate Package Version
16+
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT
17+
id: export_crate_version
18+
outputs:
19+
VERSION: ${{ steps.export_crate_version.outputs.VERSION }}
20+
21+
tag:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
timeout-minutes: 20
26+
needs: [extract-crate-version]
27+
env:
28+
VERSION: ${{ needs.extract-crate-version.outputs.VERSION }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Bump version and push tag
32+
uses: anothrNick/github-tag-action@master
33+
env:
34+
CUSTOM_TAG: v${{ env.VERSION }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Validate Release Version
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
extract-github-tag:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions-ecosystem/action-get-latest-tag@v1
15+
id: get-latest-tag
16+
- name: Extract the git tag version
17+
run: echo "VERSION=$(echo ${{ steps.get-latest-tag.outputs.tag }} | sed 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/')" >> $GITHUB_OUTPUT
18+
id: export-git-tag
19+
outputs:
20+
VERSION: ${{ steps.export-git-tag.outputs.VERSION }}
21+
22+
extract-crate-version:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Export Crate Package Version
27+
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT
28+
id: export_crate_version
29+
outputs:
30+
VERSION: ${{ steps.export_crate_version.outputs.VERSION }}
31+
32+
validate-crate-version:
33+
runs-on: ubuntu-latest
34+
needs: [extract-github-tag, extract-crate-version]
35+
env:
36+
GIT_TAG: ${{ needs.extract-github-tag.outputs.VERSION }}
37+
CRATE_VERSION: ${{ needs.extract-crate-version.outputs.VERSION }}
38+
steps:
39+
- uses: baptiste0928/cargo-install@v2
40+
with:
41+
crate: semver-util
42+
- name: Validate Semvers
43+
run: semver cmp ${{ env.CRATE_VERSION }} gt ${{ env.GIT_TAG }} || exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
22
.vscode/
3+
.helix/
34
*.svg
45
*.log

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
members = ["msg", "msg-socket", "msg-wire", "msg-transport", "msg-common"]
33

44
[workspace.package]
5-
version = "0.1.0-alpha"
5+
version = "0.1.1"
66
edition = "2021"
77
rust-version = "1.70" # Remember to update .clippy.toml and README.md
88
license = "MIT OR Apache-2.0"

0 commit comments

Comments
 (0)