-
Notifications
You must be signed in to change notification settings - Fork 3
182 lines (148 loc) · 8.17 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: New Release
# This workflow can be triggered manually with a specified version input or automatically on a push tag
on:
push:
tags:
- 'v*' # Triggers the workflow on push events that create tags matching the pattern 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version' # Description of the version input
required: true # Makes the version input mandatory
type: string # Specifies the type of the input as a string
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains 2 jobs: build and release
build_macos:
# The type of runner that the job will run on
runs-on: macos-latest # Specifies that the job runs on a macOS runner
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout sources
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
uses: actions/checkout@v4
- name: Determine Version
id: determine_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV # Sets the VERSION environment variable for workflow_dispatch
elif [ "${{ github.event_name }}" = "push" ]; then
TAG_NAME=${{ github.ref_name }}
VERSION=${TAG_NAME#v} # Removes the 'v' prefix from the tag name to get the version
echo "VERSION=${VERSION}" >> $GITHUB_ENV # Sets the VERSION environment variable for push
fi
- name: Use Version
run: echo "Using version ${{ env.VERSION }}" # Prints the version being used
- name: Setup Java 18
uses: actions/setup-java@v4 # Uses the setup-java action to set up JDK 18
with:
java-version: 18 # Specifies the version of Java to set up
architecture: x64 # Specifies the architecture of Java to set up
distribution: 'temurin' # Specifies the distribution of Java to set up (e.g., adopt, zulu, temurin)
- run: echo "JAVA_18=$JAVA_HOME" >> $GITHUB_ENV # Sets the JAVA_HOME environment variable
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3 # Uses the setup-gradle action to set up Gradle
with:
add-job-summary: on-failure
add-job-summary-as-pr-comment: on-failure
- run: ./gradlew --stacktrace --scan packageReleaseDmg # Runs the Gradle task to create a release version of DMG file
- name: Upload DMG Artifact
uses: actions/upload-artifact@v4 # Uses the upload-artifact action to upload the DMG file
with:
name: ADBugger-dmg # Name of the artifact
path: build/output/main-release/dmg/ADBugger-${{ env.VERSION }}.dmg # Path to the DMG file, using the version input
build_win:
# The type of runner that the job will run on
runs-on: windows-latest # Specifies that the job runs on a windows runner
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout sources
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
uses: actions/checkout@v4
- name: Determine Version
id: determine_version
run: |
pwsh -Command "
if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') {
Write-Host 'VERSION=' + $env:GITHUB_EVENT.inputs.version | Out-File -FilePath $env:GITHUB_ENV -Append
} elseif ($env:GITHUB_EVENT_NAME -eq 'push') {
$TAG_NAME = 'master'
$VERSION = $TAG_NAME.Substring(1)
Write-Host 'VERSION=' + $VERSION | Out-File -FilePath $env:GITHUB_ENV -Append
}
"
- name: Use Version
run: echo "Using version ${{ env.VERSION }}" # Prints the version being used
- name: Setup Java 18
uses: actions/setup-java@v4 # Uses the setup-java action to set up JDK 18
with:
java-version: 18 # Specifies the version of Java to set up
architecture: x64 # Specifies the architecture of Java to set up
distribution: 'temurin' # Specifies the distribution of Java to set up (e.g., adopt, zulu, temurin)
- run: echo "JAVA_18=$JAVA_HOME" >> $GITHUB_ENV # Sets the JAVA_HOME environment variable
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3 # Uses the setup-gradle action to set up Gradle
with:
add-job-summary: on-failure
add-job-summary-as-pr-comment: on-failure
- run: ./gradlew --stacktrace --scan packageReleaseMsi # Runs the Gradle task to create a release version of MSI file
- name: Upload MSI Artifact
uses: actions/upload-artifact@v4 # Uses the upload-artifact action to upload the MSI file
with:
name: ADBugger-msi # Name of the artifact
path: build/output/main-release/msi/ADBugger-${{ env.VERSION }}.msi # Path to the MSI file, using the version input
# A separate job to handle the release process
release:
needs: [ build_macos, build_win ] # Specifies that this job depends on the successful completion of the build job
runs-on: ubuntu-latest # Specifies that the job runs on an Ubuntu runner
steps:
- name: Determine Version
id: determine_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV # Sets the VERSION environment variable for workflow_dispatch
elif [ "${{ github.event_name }}" = "push" ]; then
TAG_NAME=${{ github.ref_name }}
VERSION=${TAG_NAME#v} # Removes the 'v' prefix from the tag name to get the version
echo "VERSION=${VERSION}" >> $GITHUB_ENV # Sets the VERSION environment variable for push
fi
- name: Use Version
run: echo "Using version ${{ env.VERSION }}" # Prints the version being used
- name: Download Artifact DMG
uses: actions/download-artifact@v4 # Uses the download-artifact action to download the previously uploaded DMG file
with:
name: ADBugger-dmg # Name of the artifact to download
path: ./ # Path to download the artifact to
- name: Download Artifact MSI
uses: actions/download-artifact@v4 # Uses the download-artifact action to download the previously uploaded MSI file
with:
name: ADBugger-msi # Name of the artifact to download
path: ./ # Path to download the artifact to
- name: Create GitHub Release
id: create_release # Sets an ID for the step to reference later
uses: actions/create-release@v1 # Uses the create-release action to create a GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Uses the GitHub token to authenticate
with:
tag_name: v${{ env.VERSION }} # Tag name for the release, using the version input
release_name: Release v${{ env.VERSION }} # Name of the release, using the version input
draft: false # Specifies that the release is not a draft
prerelease: false # Specifies that the release is not a prerelease
- name: Upload Release Asset DMG
id: upload_release_dmg
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }} # Tag name for the release, using the version input
name: Release v${{ env.VERSION }} # Name of the release, using the version input
files: ./ADBugger-${{ env.VERSION }}.dmg # Path to the DMG file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Uses the GitHub token to authenticate
- name: Upload Release Asset MSI
id: upload_release_msi
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }} # Tag name for the release, using the version input
name: Release v${{ env.VERSION }} # Name of the release, using the version input
files: ./ADBugger-${{ env.VERSION }}.msi # Path to the MSI file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Uses the GitHub token to authenticate