-
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (99 loc) · 3.26 KB
/
release.yml
File metadata and controls
122 lines (99 loc) · 3.26 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
116
117
118
119
120
121
122
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Verify release metadata
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
EXPECTED_VERSION="${{ github.event.inputs.version }}"
else
EXPECTED_VERSION="${GITHUB_REF#refs/tags/v}"
fi
MANIFEST_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if [ "$MANIFEST_VERSION" != "$EXPECTED_VERSION" ]; then
echo "::error::Cargo.toml version ${MANIFEST_VERSION} does not match release version ${EXPECTED_VERSION}"
exit 1
fi
cargo metadata --locked --format-version 1 >/dev/null
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --locked --all-features --release
- name: Run all tests
run: cargo test --locked --all-features
- name: Run integration tests
run: cargo test --locked --all-features --test '*'
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [test]
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Generate changelog
id: changelog
run: |
# Get commits since last tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"* %s (%h)" $PREV_TAG..HEAD)
else
CHANGELOG=$(git log --pretty=format:"* %s (%h)" -20)
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.version.outputs.version }}
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
## Installation
**Rust:**
```toml
[dependencies]
solverforge-maps = "${{ steps.version.outputs.version }}"
```
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}