-
Notifications
You must be signed in to change notification settings - Fork 5
65 lines (57 loc) · 1.9 KB
/
Copy pathrelease.yml
File metadata and controls
65 lines (57 loc) · 1.9 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
name: Create release
on:
workflow_dispatch:
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Read version from Cargo.toml
id: version
working-directory: host
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
- name: Validate version
run: |
VERSION="${{ steps.version.outputs.version }}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version '$VERSION' in Cargo.toml — expected semver like 1.2.3"
exit 1
fi
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "::error::Tag v$VERSION already exists — bump the version in Cargo.toml first"
exit 1
fi
- name: Create tag and GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
git tag "v$VERSION"
git push origin "v$VERSION"
gh release create "v$VERSION" \
--title "v$VERSION" \
--generate-notes
- name: Trigger GHCR image publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
gh workflow run publish-examples.yml --ref "v$VERSION"
- name: Trigger crates.io publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
gh workflow run cargo-publish.yml --ref "v$VERSION" -f dry_run=false