-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (100 loc) · 3.52 KB
/
Copy pathrelease.yml
File metadata and controls
115 lines (100 loc) · 3.52 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: create release
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-rc.*'
- 'v*.*.*-beta.*'
- 'v*.*.*-alpha.*'
- '[0-9]+.*.*'
- '[0-9]+.*.*-rc.*'
- '[0-9]+.*.*-beta.*'
- '[0-9]+.*.*-alpha.*'
permissions:
contents: write
jobs:
build:
uses: ./.github/workflows/build.yml
with:
artifact-name: release
unittest:
uses: ./.github/workflows/unittest.yml
e2e:
uses: ./.github/workflows/e2e.yml
needs: [build]
with:
artifact-id: ${{ needs.build.outputs.deb-artifact }}
release:
runs-on: ubuntu-latest
needs: [build, unittest, e2e]
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Extract version from tag
id: version
run: |
# Extract version from tag (remove 'v' prefix if present)
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION=${TAG_NAME#v}
# Detect pre-release: any SemVer build metadata or pre-release suffix
# is signaled by a '-' in the version string (e.g. 0.2.0-rc.1).
if [[ "$VERSION" == *-* ]]; then
PRERELEASE=true
else
PRERELEASE=false
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
- name: Verify version matches Cargo.toml
run: |
sudo apt-get update -y
sudo apt-get install -y wget
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
chmod +x /usr/local/bin/yq
CARGO_VERSION=$(yq eval '.package.version' Cargo.toml)
if [ "$CARGO_VERSION" != "${{ steps.version.outputs.version }}" ]; then
echo "Error: Tag version (${{ steps.version.outputs.version }}) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "Version verified: $CARGO_VERSION"
- name: Download Debian package
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build.outputs.deb-artifact }}
path: ./deb/
merge-multiple: true
- name: Download RPM package
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build.outputs.rpm-artifact }}
path: ./rpm/
merge-multiple: true
- name: Download binary
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build.outputs.bin-artifact }}
path: ./bin/
merge-multiple: true
- name: Download man page
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build.outputs.man-artifact }}
path: ./man/
merge-multiple: true
- name: Create binary tarball
run: tar -czf ${{ github.event.repository.name }}_${{ steps.version.outputs.version }}.tar.gz -C ./bin .
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ steps.version.outputs.prerelease }}
make_latest: ${{ steps.version.outputs.prerelease == 'true' && 'false' || 'true' }}
files: |
./deb/*.deb
./rpm/*.rpm
./${{ github.event.repository.name }}_${{ steps.version.outputs.version }}.tar.gz
./man/cave.1