Skip to content

Commit de6226d

Browse files
committed
Refactor workflows to use automatic tag triggers
Remove manual tag inputs from publish and bump workflows. Instead, trigger on git tags automatically and use github.ref_name to reference the current tag. Add matrix testing across multiple Rust versions and Linux distributions.
1 parent 9706c6e commit de6226d

5 files changed

Lines changed: 49 additions & 31 deletions

File tree

.github/workflows/bump-and-release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ on:
1111
- minor
1212
- major
1313
default: patch
14-
ref:
15-
description: "Branch or commit to tag"
16-
type: string
17-
default: master
1814
beta:
1915
description: "Append -beta.N suffix"
2016
type: boolean
@@ -39,7 +35,6 @@ jobs:
3935
steps:
4036
- uses: actions/checkout@v6
4137
with:
42-
ref: ${{ inputs.ref }}
4338
token: ${{ secrets.RELEASE_TOKEN }}
4439
fetch-depth: 0
4540

@@ -93,7 +88,7 @@ jobs:
9388
run: |
9489
TAG="v${{ steps.ver.outputs.next }}"
9590
git tag -a "$TAG" -m "$TAG"
96-
git push origin "${{ inputs.ref }}" --follow-tags
91+
git push origin "${{ github.ref_name }}" --follow-tags
9792
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
9893
9994
release:

.github/workflows/ci.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,51 @@ jobs:
3535

3636
test:
3737
needs: clippy
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
rust: [stable, beta]
42+
env:
43+
- name: ubuntu
44+
container: ""
45+
- name: debian
46+
container: "debian:12"
47+
- name: arch
48+
container: "archlinux:latest"
49+
- name: alpine
50+
container: "rust:1-alpine"
51+
name: test (${{ matrix.env.name }} / ${{ matrix.rust }})
3852
runs-on: ubuntu-latest
53+
container: ${{ matrix.env.container }}
3954
steps:
55+
- name: Prep (debian)
56+
if: matrix.env.name == 'debian'
57+
run: |
58+
apt-get update
59+
apt-get install -y --no-install-recommends \
60+
git curl ca-certificates build-essential pkg-config libssl-dev
61+
62+
- name: Prep (arch)
63+
if: matrix.env.name == 'arch'
64+
run: |
65+
pacman -Syu --noconfirm git curl base-devel openssl pkgconf
66+
67+
- name: Prep (alpine)
68+
if: matrix.env.name == 'alpine'
69+
shell: sh
70+
run: |
71+
apk add --no-cache git curl ca-certificates bash nodejs musl-dev
72+
4073
- uses: actions/checkout@v6
41-
- uses: dtolnay/rust-toolchain@stable
74+
75+
- uses: dtolnay/rust-toolchain@master
76+
with:
77+
toolchain: ${{ matrix.rust }}
78+
4279
- uses: Swatinem/rust-cache@v2
80+
with:
81+
key: ${{ matrix.env.name }}-${{ matrix.rust }}
82+
4383
- run: cargo test --all-features
4484

4585
build:

.github/workflows/publish-crates.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ name: Publish (crates.io)
33
on:
44
workflow_dispatch:
55
inputs:
6-
tag:
7-
description: "Tag to publish (e.g. v1.2.3)"
8-
type: string
9-
required: true
106
dry_run:
117
description: "Run cargo publish --dry-run"
128
type: boolean
139
default: false
1410

1511
jobs:
1612
publish:
13+
if: startsWith(github.ref, 'refs/tags/')
1714
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@v6
20-
with:
21-
ref: refs/tags/${{ inputs.tag }}
22-
2317
- uses: dtolnay/rust-toolchain@stable
2418
- uses: Swatinem/rust-cache@v2
2519

.github/workflows/publish-docker-hub.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ name: Publish (Docker Hub)
33
on:
44
workflow_dispatch:
55
inputs:
6-
tag:
7-
description: "Tag to publish (e.g. v1.2.3)"
8-
type: string
9-
required: true
106
image:
117
description: "Image name (namespace/name)"
128
type: string
139
required: true
1410

1511
jobs:
1612
publish:
13+
if: startsWith(github.ref, 'refs/tags/')
1714
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@v6
20-
with:
21-
ref: refs/tags/${{ inputs.tag }}
2217

2318
- uses: docker/setup-buildx-action@v3
2419
- uses: docker/login-action@v3
@@ -31,8 +26,8 @@ jobs:
3126
with:
3227
images: ${{ inputs.image }}
3328
tags: |
34-
type=raw,value=${{ inputs.tag }}
35-
type=raw,value=latest,enable=${{ !contains(inputs.tag, '-beta') }}
29+
type=raw,value=${{ github.ref_name }}
30+
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-beta') }}
3631
3732
- uses: docker/build-push-action@v5
3833
with:

.github/workflows/publish-ghcr.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ name: Publish (GHCR)
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
tag:
7-
description: "Tag to publish (e.g. v1.2.3)"
8-
type: string
9-
required: true
105

116
permissions:
127
contents: read
138
packages: write
149

1510
jobs:
1611
publish:
12+
if: startsWith(github.ref, 'refs/tags/')
1713
runs-on: ubuntu-latest
1814
steps:
1915
- uses: actions/checkout@v6
20-
with:
21-
ref: refs/tags/${{ inputs.tag }}
2216

2317
- uses: docker/setup-buildx-action@v3
2418
- uses: docker/login-action@v3
@@ -32,8 +26,8 @@ jobs:
3226
with:
3327
images: ghcr.io/${{ github.repository }}
3428
tags: |
35-
type=raw,value=${{ inputs.tag }}
36-
type=raw,value=latest,enable=${{ !contains(inputs.tag, '-beta') }}
29+
type=raw,value=${{ github.ref_name }}
30+
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-beta') }}
3731
3832
- uses: docker/build-push-action@v5
3933
with:

0 commit comments

Comments
 (0)