Skip to content

New Release

New Release #32

Workflow file for this run

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