Skip to content

Commit 56ed260

Browse files
committed
feat: Switch to semanticrelease for releases
1 parent 2af34f0 commit 56ed260

File tree

13 files changed

+6495
-197
lines changed

13 files changed

+6495
-197
lines changed

.devcontainer/Dockerfile.alpine

Lines changed: 0 additions & 8 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Build Artifacts
2+
on:
3+
workflow_call:
4+
inputs:
5+
runner:
6+
description: GitHub-hosted runner label
7+
required: true
8+
type: string
9+
toolchain:
10+
description: Rust toolchain channel to install
11+
required: true
12+
type: string
13+
artifact_glob:
14+
description: Glob pattern for build artifacts produced by build.sh
15+
required: true
16+
type: string
17+
artifact_name:
18+
description: Name to use when uploading artifacts
19+
required: true
20+
type: string
21+
upload_artifact:
22+
description: Whether to upload build artifacts
23+
required: true
24+
type: boolean
25+
run_tests:
26+
description: Run cargo test before building
27+
required: false
28+
type: boolean
29+
default: false
30+
allow_failure:
31+
description: Treat build/test failures as non-fatal
32+
required: false
33+
type: boolean
34+
default: false
35+
rpm:
36+
description: Generate an RPM artifact (Linux only)
37+
required: false
38+
type: boolean
39+
default: false
40+
release_version:
41+
description: Release version to prepare with semantic-release-cargo
42+
required: false
43+
type: string
44+
default: ""
45+
fetch_depth:
46+
description: Fetch depth for the checkout step
47+
required: false
48+
type: string
49+
default: "0"
50+
51+
jobs:
52+
build:
53+
runs-on: ${{ inputs.runner }}
54+
permissions:
55+
contents: read
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v5
59+
with:
60+
fetch-depth: ${{ inputs.fetch_depth }}
61+
62+
- name: Setup Rust
63+
uses: dtolnay/rust-toolchain@master
64+
with:
65+
toolchain: ${{ inputs.toolchain }}
66+
- name: Rust Cache
67+
uses: Swatinem/[email protected]
68+
- name: Install musl toolchain
69+
if: ${{ inputs.rpm }}
70+
run: |
71+
set -euxo pipefail
72+
sudo apt-get update
73+
sudo apt-get install -y musl-tools
74+
rustup target add x86_64-unknown-linux-musl
75+
echo "CARGO_BUILD_TARGET=x86_64-unknown-linux-musl" >> $GITHUB_ENV
76+
77+
- name: Run tests
78+
if: ${{ inputs.run_tests }}
79+
continue-on-error: ${{ inputs.allow_failure }}
80+
run: cargo test --all-features
81+
82+
- name: Install cargo-get
83+
run: cargo install --locked cargo-get
84+
85+
- name: Install semantic-release-cargo
86+
if: ${{ inputs.release_version != '' }}
87+
run: cargo install --locked semantic-release-cargo
88+
89+
- name: Install cargo-generate-rpm
90+
if: ${{ inputs.rpm }}
91+
run: cargo install --locked cargo-generate-rpm
92+
93+
- name: Prepare release version
94+
if: ${{ inputs.release_version != '' }}
95+
run: semantic-release-cargo prepare ${{ inputs.release_version }}
96+
97+
- name: Build artifacts
98+
id: build
99+
continue-on-error: ${{ inputs.allow_failure }}
100+
run: ./build.sh
101+
env:
102+
RUNNER: ${{ inputs.runner }}
103+
104+
- name: Generate RPM
105+
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
106+
run: |
107+
set -euxo pipefail
108+
mkdir -p target/release
109+
cp floki target/release/floki
110+
cargo generate-rpm
111+
112+
- name: Collect archives
113+
if: ${{ steps.build.outcome == 'success' }}
114+
run: |
115+
set -euxo pipefail
116+
rm -rf dist
117+
mkdir dist
118+
mv ${{ inputs.artifact_glob }} dist/
119+
120+
- name: Collect RPM
121+
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
122+
run: |
123+
set -euxo pipefail
124+
cp target/generate-rpm/floki*.rpm dist/
125+
126+
- name: Upload artifacts
127+
if: ${{ inputs.upload_artifact && steps.build.outcome == 'success' }}
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: ${{ inputs.artifact_name }}
131+
path: dist

.github/workflows/ci.yml

Lines changed: 62 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
name: floki-ci
22
on:
33
push:
4-
tags:
5-
# Full version
6-
- "[0-9]+.[0-9]+.[0-9]+"
7-
# Prerelease version
8-
- "[0-9]+.[0-9]+.[0-9]+-*"
4+
branches:
5+
- main
96

107
pull_request:
118
branches:
@@ -23,172 +20,83 @@ jobs:
2320
uses: dtolnay/rust-toolchain@master
2421
with:
2522
toolchain: stable
23+
- name: Rust Cache
24+
uses: Swatinem/[email protected]
2625
- name: Run cargo clippy to pick up any errors
2726
run: cargo clippy --all-targets -- -Dwarnings
2827
- name: Check code is formatted
2928
run: cargo fmt -- --check
3029

3130
build:
32-
name: Build static binary for publishing
33-
runs-on: ${{ matrix.os }}
34-
continue-on-error: ${{ matrix.experimental }}
31+
name: Build ${{ matrix.name }}
3532
strategy:
3633
matrix:
37-
os:
38-
- ubuntu-24.04
39-
- macos-latest
40-
rust:
41-
- stable
42-
- beta
43-
experimental: [false]
4434
include:
45-
- os: ubuntu-24.04
35+
- name: linux-stable
36+
os: ubuntu-24.04
37+
rust: stable
38+
artifact_glob: floki-*.tar.gz
39+
artifact_name: dist-linux
40+
upload_artifact: true
41+
rpm: true
42+
allow_failure: false
43+
- name: linux-beta
44+
os: ubuntu-24.04
45+
rust: beta
46+
artifact_glob: floki-*.tar.gz
47+
artifact_name: linux-beta
48+
upload_artifact: false
49+
rpm: false
50+
allow_failure: false
51+
- name: linux-nightly
52+
os: ubuntu-24.04
4653
rust: nightly
47-
experimental: true
48-
steps:
49-
- uses: actions/checkout@v5
50-
- name: Install rust
51-
uses: dtolnay/rust-toolchain@master
52-
with:
53-
toolchain: ${{ matrix.rust }}
54-
- name: Install cargo-get
55-
run: cargo install cargo-get
56-
- name: Run tests
57-
run: cargo test --all-features
58-
- run: "./build.sh"
59-
env:
60-
OS_NAME: ${{ matrix.os }}
61-
- name: Archive artifacts
62-
uses: actions/upload-artifact@v5
63-
if: ${{ matrix.rust == 'stable' }}
64-
with:
65-
name: stableartifacts-${{ matrix.os }}
66-
path: |
67-
floki*.zip
68-
floki*.tar.gz
54+
artifact_glob: floki-*.tar.gz
55+
artifact_name: linux-nightly
56+
upload_artifact: false
57+
rpm: false
58+
allow_failure: true
59+
- name: macos-stable
60+
os: macos-latest
61+
rust: stable
62+
artifact_glob: floki-*.zip
63+
artifact_name: dist-macos
64+
upload_artifact: true
65+
rpm: false
66+
allow_failure: false
67+
- name: macos-beta
68+
os: macos-latest
69+
rust: beta
70+
artifact_glob: floki-*.zip
71+
artifact_name: macos-beta
72+
upload_artifact: false
73+
rpm: false
74+
allow_failure: false
75+
uses: ./.github/workflows/build-artifacts.yml
76+
with:
77+
runner: ${{ matrix.os }}
78+
toolchain: ${{ matrix.rust }}
79+
artifact_glob: ${{ matrix.artifact_glob }}
80+
artifact_name: ${{ matrix.artifact_name }}
81+
upload_artifact: ${{ matrix.upload_artifact }}
82+
run_tests: true
83+
rpm: ${{ matrix.rpm }}
84+
allow_failure: ${{ matrix.allow_failure }}
85+
fetch_depth: '1'
6986

70-
7187
rpm:
72-
name: Build and test RPM using cargo generate-rpm
88+
name: Verify RPM installation
7389
runs-on: ubuntu-24.04
7490
needs: build
7591
steps:
76-
- uses: actions/checkout@v5
77-
- name: Install rust
78-
uses: dtolnay/rust-toolchain@master
79-
with:
80-
toolchain: stable
81-
- name: Install cargo-generate-rpm
82-
run: cargo install cargo-generate-rpm
83-
# Download the ubuntu artifact instead of rebuilding.
84-
- name: Download artifacts
92+
- name: Download linux artifacts
8593
uses: actions/download-artifact@v6
8694
with:
87-
name: stableartifacts-ubuntu-24.04
88-
- name: Build RPM
89-
run: |
90-
tar -xzvf floki*.tar.gz
91-
mkdir -p target/release
92-
cp floki target/release/floki
93-
cargo generate-rpm
94-
- name: Debug
95-
run: |
96-
set -ex
97-
98-
ls -ltR .
99-
ls -l /usr/bin
100-
95+
name: dist-linux
96+
path: dist-linux
10197
- name: Install RPM
102-
run: find . -name "floki*.rpm" | xargs sudo rpm -ivh
98+
run: |
99+
set -euxo pipefail
100+
find dist-linux -name "floki*.rpm" -exec sudo rpm -ivh {} \;
103101
- name: Test installation
104102
run: floki -V
105-
- name: Archive artifacts
106-
uses: actions/upload-artifact@v5
107-
with:
108-
name: rpm
109-
path: |
110-
target/generate-rpm/floki*.rpm
111-
112-
publish:
113-
name: Publish release artifact
114-
runs-on: ubuntu-latest
115-
if: github.ref_type == 'tag'
116-
needs:
117-
- build
118-
- rpm
119-
# Required to publish a release
120-
permissions:
121-
contents: write
122-
steps:
123-
- uses: actions/checkout@v5
124-
- name: Install rust
125-
uses: dtolnay/rust-toolchain@master
126-
with:
127-
toolchain: stable
128-
- name: Install cargo-get
129-
run: cargo install cargo-get
130-
- name: Publish to crates.io
131-
run: cargo publish
132-
env:
133-
CARGO_REGISTRY_TOKEN: ${{ secrets.PUBLISH_SECRET }}
134-
# After publishing, create a release
135-
- name: Download ubuntu artifacts
136-
uses: actions/download-artifact@v6
137-
with:
138-
name: stableartifacts-ubuntu-24.04
139-
- name: Download macos artifacts
140-
uses: actions/download-artifact@v6
141-
with:
142-
name: stableartifacts-macos-latest
143-
- name: Download RPM
144-
uses: actions/download-artifact@v6
145-
with:
146-
name: rpm
147-
- name: Generate release.txt
148-
run: "./changelog.sh"
149-
- name: Release
150-
uses: softprops/action-gh-release@v2
151-
with:
152-
body_path: release.txt
153-
files: |
154-
floki*.zip
155-
floki*.tar.gz
156-
floki*.rpm
157-
# # Announce the release
158-
# - run: "./announce.sh"
159-
# env:
160-
# ANNOUNCE_HOOK: ${{ secrets.ANNOUNCE_HOOK }}
161-
162-
publish-dry-run:
163-
name: Dry-run publish for non-release artifact
164-
runs-on: ubuntu-latest
165-
if: github.ref_type != 'tag'
166-
needs:
167-
- build
168-
- rpm
169-
steps:
170-
- uses: actions/checkout@v5
171-
- name: Install rust
172-
uses: dtolnay/rust-toolchain@master
173-
with:
174-
toolchain: stable
175-
- name: Install cargo-get
176-
run: cargo install cargo-get
177-
- name: Dry-run publish on non-tags
178-
run: cargo publish --dry-run
179-
# Test downloading the artifacts
180-
- name: Download ubuntu artifacts
181-
uses: actions/download-artifact@v6
182-
with:
183-
name: stableartifacts-ubuntu-24.04
184-
- name: Download macos artifacts
185-
uses: actions/download-artifact@v6
186-
with:
187-
name: stableartifacts-macos-latest
188-
- name: Download rpm
189-
uses: actions/download-artifact@v6
190-
with:
191-
name: rpm
192-
# Test generating release.txt
193-
- name: Generate release.txt
194-
run: "./changelog.sh"

0 commit comments

Comments
 (0)