-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (108 loc) · 3.68 KB
/
Copy pathrelease.yml
File metadata and controls
129 lines (108 loc) · 3.68 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
123
124
125
126
127
128
129
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:
if: ${{ github.server_url == 'https://github.com' }}
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
run: |
rm -rf .git
git init .
git remote add origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git"
git fetch --depth=1 origin "${{ github.sha }}"
git checkout --detach FETCH_HEAD
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
- name: Build
run: cargo build --release
- name: Run tests
run: |
cargo test
node --test tests/*.test.js
create-release:
if: ${{ github.server_url == 'https://github.com' }}
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout repository
run: |
rm -rf .git
git init .
git remote add origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git"
git fetch --force --tags origin "+refs/heads/*:refs/remotes/origin/*"
git fetch --force origin "${{ github.sha }}"
git checkout --detach FETCH_HEAD
- 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: Extract changelog entry
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
CHANGELOG_RE="^## (\\[)?${VERSION//./\\.}(\\]| )"
SECTION=$(awk "/${CHANGELOG_RE}/{flag=1; next} /^## /{flag=0} flag" CHANGELOG.md)
if ! grep -qE "${CHANGELOG_RE}" CHANGELOG.md; then
echo "Missing CHANGELOG.md entry for version $VERSION" >&2
exit 1
fi
CHANGELOG="$SECTION"
if [ -z "$CHANGELOG" ]; then
CHANGELOG="- See CHANGELOG.md for version $VERSION."
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cat <<'EOF' > release-notes.md
## What's Changed
${{ steps.changelog.outputs.changelog }}
## Installation
```toml
[dependencies]
solverforge-ui = "${{ steps.version.outputs.version }}"
```
EOF
release_args=(
"v${{ steps.version.outputs.version }}"
--target "${{ github.sha }}"
--title "v${{ steps.version.outputs.version }}"
--notes-file release-notes.md
--verify-tag
)
if [[ "${{ steps.version.outputs.version }}" == *-* ]]; then
release_args+=(--prerelease)
fi
if gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
gh release edit "${release_args[@]}"
else
gh release create "${release_args[@]}"
fi