-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (142 loc) · 4.94 KB
/
Copy pathrelease.yml
File metadata and controls
168 lines (142 loc) · 4.94 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- name: windows-x86_64
target: x86_64-pc-windows-msvc
os: windows-latest
lib: rustyjavac_native.dll
- name: linux-x86_64
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
lib: rustyjavac_native.so
- name: macos-x86_64
target: x86_64-apple-darwin
os: macos-latest
lib: rustyjavac_native.dylib
- name: macos-aarch64
target: aarch64-apple-darwin
os: macos-latest
lib: rustyjavac_native.dylib
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Rename artifact
shell: bash
run: |
src=$(find target/${{ matrix.target }}/release -maxdepth 1 -name "*rustyjavac_native*" \( -name "*.so" -o -name "*.dylib" -o -name "*.dll" \) | head -1)
if [ ! -f "$src" ]; then
echo "ERROR: built library not found. Listing release dir:"
ls -la target/${{ matrix.target }}/release/*.so target/${{ matrix.target }}/release/*.dylib target/${{ matrix.target }}/release/*.dll 2>/dev/null || true
exit 1
fi
echo "Found: $src"
cp "$src" ${{ matrix.lib }}
- name: Generate SHA-256
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
certutil -hashfile ${{ matrix.lib }} SHA256 | grep -E '^[a-fA-F0-9]{64}$' | tr '[:upper:]' '[:lower:]' > ${{ matrix.lib }}.sha256
else
shasum -a 256 ${{ matrix.lib }} | awk '{print $1}' > ${{ matrix.lib }}.sha256
fi
echo "sha256=$(cat ${{ matrix.lib }}.sha256)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
${{ matrix.lib }}
${{ matrix.lib }}.sha256
if-no-files-found: error
changelog:
name: Generate changelog
runs-on: ubuntu-latest
outputs:
body: ${{ steps.changelog.outputs.body }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
shell: bash
run: |
set -ex
TAG_NAME="${GITHUB_REF_NAME}"
echo "tag=$TAG_NAME"
PREV_TAG=$(git tag --sort=-creatordate | grep -v "^$TAG_NAME$" | head -1 || true)
echo "prev_tag=${PREV_TAG:-<none>}"
RANGE="${PREV_TAG:+$PREV_TAG..HEAD}"
RANGE="${RANGE:-HEAD}"
echo "range=$RANGE"
echo "## Changes" > /tmp/changelog.md
echo "" >> /tmp/changelog.md
has_commits=false
while IFS= read -r line; do
has_commits=true
message="${line% *}"
hash="${line##* }"
echo " commit: $message ($hash)"
case "$message" in
feat*) emoji="🚀 feat" ;;
fix*) emoji="🐛 fix" ;;
perf*) emoji="⚡ perf" ;;
refactor*) emoji="♻️ refactor" ;;
test*) emoji="✅ test" ;;
docs*) emoji="📝 docs" ;;
chore*) emoji="🔧 chore" ;;
ci*) emoji="👷 ci" ;;
*) emoji="📦 other" ;;
esac
clean_msg=$(echo "$message" | sed -E 's/^[a-z]+(\([^)]*\))?: ?//')
echo "- **$emoji**: $clean_msg (\`$hash\`)" >> /tmp/changelog.md
done < <(git log "$RANGE" --pretty=format:"%s %h" --no-merges || true)
if [ "$has_commits" = false ]; then
echo "_no new commits since last tag_" >> /tmp/changelog.md
fi
echo "--- changelog ---"
cat /tmp/changelog.md
echo "--- end ---"
{
echo "body<<EOF"
cat /tmp/changelog.md
echo "EOF"
} >> "$GITHUB_OUTPUT"
release:
name: Create GitHub Release
needs: [build, changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: "*"
path: artifacts
- name: Show artifacts
run: ls -laR artifacts/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
body: ${{ needs.changelog.outputs.body }}
files: |
artifacts/**/rustyjavac_native.dll
artifacts/**/rustyjavac_native.so
artifacts/**/rustyjavac_native.dylib
fail_on_unmatched_files: true
generate_release_notes: false