Skip to content

Commit a478c53

Browse files
authored
Create prereleases on push to main, and allow manual dispatch to create prereleases on other branches
1 parent c5d36eb commit a478c53

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@
77

88
name: Gradle Package
99

10-
11-
on:
10+
on:
1211
release:
13-
types: [created]
12+
types: [created]
13+
push:
14+
branches:
15+
- main
16+
workflow_dispatch:
17+
inputs:
18+
prerelease_tag:
19+
description: 'Tag name for the prerelease (e.g., v1.0.0-beta.1)'
20+
required: true
21+
type: string
1422

15-
jobs:
16-
build:
23+
jobs:
24+
build:
1725

18-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-latest
1927
permissions:
2028
contents: write
2129
packages: write
@@ -24,11 +32,11 @@ jobs:
2432
- uses: actions/checkout@v4
2533
- name: Set up JDK 17
2634
uses: actions/setup-java@v4
27-
with:
35+
with:
2836
java-version: '17'
2937
distribution: 'temurin'
30-
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
31-
settings-path: ${{ github.workspace }} # location for the settings.xml file
38+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
39+
settings-path: ${{ github. workspace }} # location for the settings.xml file
3240

3341
- name: Setup Gradle
3442
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
@@ -38,13 +46,44 @@ jobs:
3846

3947
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
4048
# the publishing section of your build.gradle
41-
- name: Publish to GitHub Packages
42-
run: ./gradlew publish
43-
env:
49+
- name: Publish to GitHub Packages
50+
run: ./gradlew publish
51+
env:
4452
USERNAME: ${{ github.actor }}
4553
TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
54+
55+
# Upload release asset for official releases
4756
- name: Upload Release Asset
57+
if: github.event_name == 'release'
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
files: build/libs/showscript.jar
61+
62+
# Create prerelease on push to main
63+
- name: Create Prerelease on Push to Main
64+
if: github.event_name == 'push' && github. ref == 'refs/heads/main'
4865
uses: softprops/action-gh-release@v2
4966
with:
67+
tag_name: prerelease-${{ github.sha }}
68+
name: Prerelease ${{ github.sha }}
69+
prerelease: true
70+
files: build/libs/showscript.jar
71+
body: |
72+
Automated prerelease from commit ${{ github.sha }}
73+
74+
Branch: main
75+
Commit: ${{ github. event.head_commit. message }}
76+
77+
# Create prerelease on manual dispatch
78+
- name: Create Prerelease on Manual Dispatch
79+
if: github.event_name == 'workflow_dispatch'
80+
uses: softprops/action-gh-release@v2
81+
with:
82+
tag_name: ${{ inputs.prerelease_tag }}
83+
name: Prerelease ${{ inputs.prerelease_tag }}
84+
prerelease: true
5085
files: build/libs/showscript.jar
86+
body: |
87+
Manual prerelease from branch ${{ github.ref_name }}
88+
89+
Commit: ${{ github.sha }}

0 commit comments

Comments
 (0)