forked from vlsi/ksar
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (87 loc) · 3.37 KB
/
release-drafter.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release Drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize]
jobs:
update_release_draft:
# Skip release drafts in forks
if: github.repository_owner == 'vlsi'
name: Update Release Draft
runs-on: ubuntu-latest
env:
# Publish pre-release files to a draft release
PUBLISH_SNAPSHOT: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
# Drafts your next Release notes as Pull Requests are merged into "master"
- name: Update release body draft
uses: release-drafter/release-drafter@v6
id: prepare_release
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout sources
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/checkout@v4
- name: Set up JDK 17
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/setup-java@v4
with:
java-version: 17
distribution: liberica
- name: Build
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: burrunan/gradle-cache-action@v2
with:
job-id: jdk17
arguments: --scan --no-parallel --no-daemon shadowJar
- name: Attach files to release
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/github-script@v7
env:
# 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 {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 globber = await glob.create('build/libs/ksar-*-all.jar');
const files = await globber.glob();
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
name: files[0].replace(/^(.*build\/libs\/ksar-)/, "ksar-"),
release_id: RELEASE_ID,
data: fs.readFileSync(files[0])
})