-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (83 loc) · 2.93 KB
/
dev_build.yml
File metadata and controls
99 lines (83 loc) · 2.93 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
name: Development build
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build
- name: Generate changelog
id: changelog
run: |
ALL_TAGS=$(git tag --sort=-v:refname)
LATEST_TAG=""
for tag in $ALL_TAGS; do
if [[ $tag != "dev" ]]; then
LATEST_TAG=$tag
break
fi
done
echo "latest_tag=$LATEST_TAG" >> $GITHUB_ENV
if [ -z "$LATEST_TAG" ]; then
COMMIT_LOG=$(git log --pretty=format:'- [`%h`](https://github.com/${{ github.repository }}/commit/%H) %s (%an)')
else
COMMIT_LOG=$(git log $LATEST_TAG..HEAD --pretty=format:'- [`%h`](https://github.com/${{ github.repository }}/commit/%H) %s (%an)')
fi
echo "commits<<EOF" >> $GITHUB_ENV
echo "$COMMIT_LOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Delete dev release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Get all releases and fetch the one with "dev" tag
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const devRelease = releases.find(release => release.tag_name === 'dev');
// Delete the "dev" release and tag if it's found.
if (devRelease) {
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: devRelease.id
});
console.log(`Successfully deleted the dev release. ID: ${devRelease.id}`);
// Delete the tag
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/dev'
});
console.log('Successfully deleted the "dev" tag.');
} catch (error) {
console.log(`Error deleting tag: ${error.message}`);
}
}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: dev
name: Development Build
prerelease: true
body: ${{ env.commits || 'No changelog generated' }}
files: build/libs/LanguageLib-*.jar