Skip to content

Commit f0278ea

Browse files
authored
chore(ci): run ci/cd and also prepare docs (#3)
* chore: docs for publishing * chore: update cd refs
1 parent e1b57fa commit f0278ea

File tree

15 files changed

+516
-12
lines changed

15 files changed

+516
-12
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
Developer's Certificate of Origin 1.1
3+
4+
By making a contribution to this project, I certify that:
5+
6+
(a) The contribution was created in whole or in part by me and I
7+
have the right to submit it under the open source license
8+
indicated in the file; or
9+
10+
(b) The contribution is based upon previous work that, to the best
11+
of my knowledge, is covered under an appropriate open source
12+
license and I have the right under that license to submit that
13+
work with modifications, whether created in whole or in part
14+
by me, under the same open source license (unless I am
15+
permitted to submit under a different license), as indicated
16+
in the file; or
17+
18+
(c) The contribution was provided directly to me by some other
19+
person who certified (a), (b) or (c) and I have not modified
20+
it.
21+
22+
(d) I understand and agree that this project and the contribution
23+
are public and that a record of the contribution (including all
24+
personal information I submit with it, including my sign-off) is
25+
maintained indefinitely and may be redistributed consistent with
26+
this project or the open source license(s) involved.
27+
-->

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'cargo'
4+
directory: '/'
5+
schedule:
6+
interval: 'weekly'

.github/workflows/cd.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Continuous Delivery
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
type: choice
8+
required: true
9+
description: 'Version number to bump'
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
pull_request:
15+
branches:
16+
- main
17+
types:
18+
- closed
19+
20+
permissions:
21+
contents: write
22+
issues: write
23+
pull-requests: write
24+
25+
jobs:
26+
publish-dry-run:
27+
name: "Runs cargo publish --dry-run"
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v6
32+
33+
- name: Setup Rust
34+
uses: dtolnay/rust-toolchain@stable
35+
36+
- name: Setup Rust Cache
37+
uses: Swatinem/rust-cache@v2
38+
39+
- name: Setup Cargo Binstall
40+
uses: cargo-bins/cargo-binstall@main
41+
42+
- name: Install Rust Binaries
43+
run: cargo binstall -y --force cargo-tag
44+
45+
- name: Build (debug)
46+
run: cargo b
47+
48+
- name: publish crate
49+
run: |
50+
cargo package --list --allow-dirty
51+
cargo publish --dry-run --allow-dirty
52+
53+
build-binaries:
54+
name: Build binaries
55+
needs: publish-dry-run
56+
strategy:
57+
matrix:
58+
include:
59+
- name: linux-x64
60+
os: ubuntu-latest
61+
target: x86_64-unknown-linux-gnu
62+
- name: linux-arm64
63+
os: ubuntu-latest
64+
target: aarch64-unknown-linux-gnu
65+
- name: macos-x64
66+
os: macos-latest
67+
target: x86_64-apple-darwin
68+
- name: macos-arm64
69+
os: macos-latest
70+
target: aarch64-apple-darwin
71+
runs-on: ${{ matrix.os }}
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v6
75+
76+
- name: Setup Rust
77+
uses: dtolnay/rust-toolchain@stable
78+
with:
79+
targets: ${{ matrix.target }}
80+
81+
- name: Setup Rust Cache
82+
uses: Swatinem/rust-cache@v2
83+
84+
- name: Install Linker for ARM64 Linux GNU
85+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
86+
run: |
87+
sudo apt-get update
88+
sudo apt-get install -y gcc-aarch64-linux-gnu
89+
90+
- name: Setup Cargo Binstall
91+
uses: cargo-bins/cargo-binstall@main
92+
93+
- name: Install Rust Binaries
94+
run: cargo binstall -y --force cargo-tag
95+
96+
- name: Retrieve Git Commit SHA
97+
run: echo "GIT_COMMIT_SHA7=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
98+
99+
- name: Retrieve Version
100+
run: |
101+
git config --global user.name 'github-actions[bot]'
102+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
103+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
104+
echo "CRATE_VERSION=$(cargo tag --no-tag --no-commit -p=v ${{ inputs.version }})" >> $GITHUB_ENV
105+
else
106+
echo "CRATE_VERSION=$(cargo tag --no-tag --no-commit -p=v prerelease pre.$GIT_COMMIT_SHA7)" >> $GITHUB_ENV
107+
fi
108+
109+
- name: Build binary
110+
run: cargo build --release --target ${{ matrix.target }}
111+
112+
- name: Package binary
113+
run: |
114+
# Create binary name with version and target
115+
BINARY_NAME="mate-${{ env.CRATE_VERSION }}-${{ matrix.name }}"
116+
117+
# Copy and rename binary
118+
if [ "${{ matrix.os }}" == "ubuntu-latest" ] || [ "${{ matrix.os }}" == "macos-latest" ]; then
119+
cp target/${{ matrix.target }}/release/mate $BINARY_NAME
120+
fi
121+
122+
# Create tar.gz archive
123+
tar -czf $BINARY_NAME.tar.gz $BINARY_NAME
124+
125+
# Store artifact name for later use
126+
echo "ARTIFACT_NAME=$BINARY_NAME.tar.gz" >> $GITHUB_ENV
127+
128+
- name: Upload binary artifact
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: ${{ env.ARTIFACT_NAME }}
132+
path: ${{ env.ARTIFACT_NAME }}
133+
134+
release:
135+
name: Create Release
136+
needs: build-binaries
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Checkout
140+
uses: actions/checkout@v6
141+
142+
- name: Setup Rust
143+
uses: dtolnay/rust-toolchain@stable
144+
with:
145+
targets: ${{ matrix.target }}
146+
147+
- name: Setup Rust Cache
148+
uses: Swatinem/rust-cache@v2
149+
150+
- name: Setup Cargo Binstall
151+
uses: cargo-bins/cargo-binstall@main
152+
153+
- name: Install Rust Binaries
154+
run: cargo binstall -y --force cargo-tag
155+
156+
- name: Retrieve Git Commit SHA
157+
run: echo "GIT_COMMIT_SHA7=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
158+
159+
- name: Commit Version Bump
160+
run: |
161+
git config --global user.name 'github-actions[bot]'
162+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
163+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
164+
echo "CRATE_VERSION=$(cargo tag -p=v ${{ inputs.version }})" >> $GITHUB_ENV
165+
else
166+
echo "CRATE_VERSION=$(cargo tag -p=v prerelease pre.$GIT_COMMIT_SHA7)" >> $GITHUB_ENV
167+
fi
168+
git push origin main --follow-tags
169+
170+
- name: Download all artifacts
171+
uses: actions/download-artifact@v4
172+
with:
173+
path: ./artifacts
174+
175+
- name: Create Release with GitHub CLI
176+
env:
177+
GH_TOKEN: ${{ github.token }}
178+
run: |
179+
# Determine if this is a pre-release
180+
IS_PRERELEASE=""
181+
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
182+
IS_PRERELEASE="--prerelease"
183+
fi
184+
185+
# Create the release
186+
gh release create "${{ env.CRATE_VERSION }}" \
187+
--title "Release ${{ env.CRATE_VERSION }}" \
188+
--generate-notes \
189+
$IS_PRERELEASE
190+
191+
# Upload all binary artifacts
192+
for artifact_dir in ./artifacts/*/; do
193+
if [ -d "$artifact_dir" ]; then
194+
for file in "$artifact_dir"*.tar.gz; do
195+
if [ -f "$file" ]; then
196+
echo "Uploading $(basename "$file")"
197+
gh release upload "${{ env.CRATE_VERSION }}" "$file"
198+
fi
199+
done
200+
fi
201+
done

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Continuous Integration
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
cq:
10+
name: Codebase Quality
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v6
15+
16+
- name: Setup Rust
17+
uses: dtolnay/rust-toolchain@stable
18+
19+
- name: Run Formatter Check
20+
run: cargo fmt --all -- --check
21+
22+
- name: Run Clippy Check
23+
run: cargo clippy --all-targets --all-features -- -D warnings
24+
25+
- name: Run Tests
26+
run: cargo test --all-features

.github/workflows/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Dependabot Automation
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@v1.1.1
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
19+
- name: Approve a PR
20+
run: gh pr review --approve "$PR_URL"
21+
env:
22+
PR_URL: ${{github.event.pull_request.html_url}}
23+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24+
25+
- name: Enable auto-merge for Dependabot PRs
26+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
27+
run: gh pr merge --auto --squash "$PR_URL"
28+
env:
29+
PR_URL: ${{github.event.pull_request.html_url}}
30+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[workspace]
2-
members = ["./src/*", "./examples/*"]
2+
members = ["./src/*", "./jobs/*"]
33
default-members = ["src/mate"]
44
resolver = "3"
55

66
[workspace.package]
77
authors = ["Leo Borai <estebanborai@gmail.com>"]
88
version = "0.0.0"
99
edition = "2024"
10-
description = ""
11-
documentation = ""
10+
categories = ["web-programming"]
11+
description = "🦀🧡🧉"
12+
documentation = "https://docs.rs/mate"
1213

1314
[workspace.dependencies]
1415
anyhow = "1.0"

Justfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ default:
22
@echo "No default task defined."
33
just --list
44

5-
build-example-http:
5+
# Builds the example job "http"
6+
build-job-http:
67
rm ./http.wasm || true
7-
cd ./examples/http && cargo +nightly build --release --target wasm32-wasip2
8+
cd ./jobs/http && cargo +nightly build --release --target wasm32-wasip2
89
mv ./target/wasm32-wasip2/release/http.wasm ./http.wasm

0 commit comments

Comments
 (0)