-
-
Notifications
You must be signed in to change notification settings - Fork 4
74 lines (63 loc) · 2.05 KB
/
Copy pathpublish.yml
File metadata and controls
74 lines (63 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# .github/workflows/publish.yml
name: Publish (crates.io)
on:
push:
tags:
- "v*.*.*" # e.g. v1.2.3
workflow_dispatch: # allow manual runs
permissions:
contents: write
id-token: write
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
publish-crate:
name: Publish to crates.io
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Cache and install APT packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
version: "1.0"
# Toolchain
- uses: dtolnay/rust-toolchain@stable
# Verify Cargo.toml version matches the tag
- name: Verify crate version matches tag
shell: bash
run: |
CRATE_VERSION=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')
TAG_VERSION=${GITHUB_REF#refs/tags/v}
test "$CRATE_VERSION" = "$TAG_VERSION" || (echo "Tag $TAG_VERSION != Cargo.toml $CRATE_VERSION" && exit 1)
# Dry run first (good practice)
- name: cargo publish (dry run)
run: cargo publish --dry-run
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: publish-crate
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
generate_release_notes: true
draft: true
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}