-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (68 loc) · 2.23 KB
/
release-reusable.yml
File metadata and controls
79 lines (68 loc) · 2.23 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
name: Release Reusable
on:
workflow_call:
inputs:
runner:
required: true
type: string
target:
required: true
type: string
archive_name:
required: true
type: string
publish_release_notes:
required: true
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: ${{ inputs.runner }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Verify tag matches Cargo.toml version
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
cargo_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"
if [[ "${tag_version}" != "${cargo_version}" ]]; then
echo "tag version ${tag_version} does not match Cargo.toml version ${cargo_version}" >&2
exit 1
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ inputs.target }}
- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: cargo build --release --target ${{ inputs.target }}
- name: Package release archive
shell: bash
run: |
set -euo pipefail
mkdir -p dist
cp "target/${{ inputs.target }}/release/devloop" dist/devloop
tar -C dist -czf "${{ inputs.archive_name }}" devloop
- name: Extract release notes from changelog
if: inputs.publish_release_notes
shell: bash
run: |
set -euo pipefail
./scripts/release-notes-from-changelog.sh "${GITHUB_REF_NAME#v}" "${GITHUB_REPOSITORY}" > release-notes.md
- name: Publish GitHub release asset
if: inputs.publish_release_notes
uses: softprops/action-gh-release@v2
with:
files: ${{ inputs.archive_name }}
body_path: release-notes.md
fail_on_unmatched_files: true
- name: Publish GitHub release asset without notes
if: ${{ !inputs.publish_release_notes }}
uses: softprops/action-gh-release@v2
with:
files: ${{ inputs.archive_name }}
fail_on_unmatched_files: true