-
Notifications
You must be signed in to change notification settings - Fork 26
68 lines (58 loc) · 1.87 KB
/
release-on-version-change.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
name: Release on Version Change
on:
push:
branches:
- master
paths:
- '**/build.gradle.kts'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Get project version
id: get_version
run: |
# Run Gradle to get the project version
version=$(./gradlew -q printVersion)
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Check if version has changed
id: check_version
run: |
latest_version=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
current_version=${{ env.VERSION }}
echo "Latest version: $latest_version"
echo "Current version: $current_version"
if [ "$current_version" != "$latest_version" ]; then
echo "::set-output name=version_changed::true"
else
echo "::set-output name=version_changed::false"
fi
- name: Create GitHub Release
if: steps.check_version.outputs.version_changed == 'true'
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
Release of version ${{ env.VERSION }}.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Log the output for debugging
- name: Log Release Creation Status
run: |
echo "Release creation status:"
echo "${{ steps.create_release.outputs }}"