-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (113 loc) · 3.65 KB
/
release.yml
File metadata and controls
137 lines (113 loc) · 3.65 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
name: Release
on:
push:
branches:
- main
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
release:
runs-on: windows-latest
steps:
# Checkout FIRST (needed to read package.json)
- uses: actions/checkout@v4
# Get version early
- name: Get version
id: version
shell: pwsh
run: |
$pkg = Get-Content package.json | ConvertFrom-Json
$version = $pkg.version
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "tag=v$version" >> $env:GITHUB_OUTPUT
echo "name=jrc-v$version" >> $env:GITHUB_OUTPUT
# Get latest release
- name: Get latest release
id: latest
uses: actions/github-script@v7
with:
script: |
try {
const res = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
return res.data.tag_name;
} catch (e) {
return null;
}
# Decide if we should continue
- name: Check if version changed
id: should_release
shell: bash
run: |
echo "Latest: ${{ steps.latest.outputs.result }}"
echo "Current: ${{ steps.version.outputs.tag }}"
if [ "${{ steps.latest.outputs.result }}" = "${{ steps.version.outputs.tag }}" ]; then
echo "release=false" >> $GITHUB_OUTPUT
echo "No version change → stopping early"
else
echo "release=true" >> $GITHUB_OUTPUT
echo "Version changed → continue"
fi
# 🚀 HARD STOP (nothing else runs)
- name: Stop if no release
if: steps.should_release.outputs.release == 'false'
run: exit 0
# -------------------------
# ONLY RUNS IF VERSION CHANGED
# -------------------------
- name: Setup Node
if: steps.should_release.outputs.release == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install deps
if: steps.should_release.outputs.release == 'true'
run: npm ci
- name: Build (dist)
if: steps.should_release.outputs.release == 'true'
run: npm run dist
# Find EXE
- name: Locate EXE
if: steps.should_release.outputs.release == 'true'
id: exe
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
$file = Get-ChildItem -Recurse -Filter "Java Runner Client Setup $version.exe" | Select-Object -First 1
if (-not $file) {
Write-Error "EXE not found"
exit 1
}
echo "path=$($file.FullName)" >> $env:GITHUB_OUTPUT
# Release notes
- name: Generate release notes
if: steps.should_release.outputs.release == 'true'
run: |
cat <<EOF > RELEASE_NOTES.md
### Version ${{ steps.version.outputs.name }}
Bugfixes:
- [...]
___
Additions:
- [...]
___
Adjustments/Changes:
- [...]
EOF
shell: bash
# Create release
- name: Create draft release
if: steps.should_release.outputs.release == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.name }}
body_path: RELEASE_NOTES.md
draft: true
files: ${{ steps.exe.outputs.path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}