forked from vlsi/ksar
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (70 loc) · 2.37 KB
/
release.yml
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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: liberica
- name: Build
uses: burrunan/gradle-cache-action@v2
with:
job-id: jdk17
arguments: --scan --no-parallel --no-daemon -Prelease build
- name: Prepare GitHub Release
id: prepare_release
uses: release-drafter/release-drafter@v6
with:
tag: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attach files to release
uses: actions/github-script@v7
env:
TAG: ${{ github.ref_name }}
# https://github.com/release-drafter/release-drafter#action-outputs
RELEASE_ID: ${{ steps.prepare_release.outputs.id }}
with:
# language=JavaScript
script: |
const fs = require('fs');
const {TAG, RELEASE_ID} = process.env;
// remove old jar files from the release
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: RELEASE_ID
});
for (const asset of assets.data) {
if (asset.name.endsWith('-all.jar')) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
}
const version = TAG.substring(1); // remove leading v
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
name: "ksar-" + version + ".jar",
release_id: RELEASE_ID,
data: fs.readFileSync("build/libs/ksar-" + version + "-all.jar")
})
- name: Publish GitHub Release
id: publish_release
uses: release-drafter/release-drafter@v6
with:
publish: true
tag: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}