Create gradle-publish.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle | ||
name: Gradle Package | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
- name: Build with Gradle | ||
run: ./gradlew build | ||
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in | ||
# the publishing section of your build.gradle | ||
- name: Publish to GitHub Packages | ||
run: ./gradlew publish | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Download a Build Artifact | ||
uses: actions/[email protected] | ||
with: | ||
# Name of the artifact to download. If unspecified, all artifacts for the run are downloaded. | ||
name: # optional | ||
# Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE | ||
path: # optional | ||
# A glob pattern matching the artifacts that should be downloaded. Ignored if name is specified. | ||
pattern: # optional | ||
# When multiple artifacts are matched, this changes the behavior of the destination directories. If true, the downloaded artifacts will be in the same directory specified by path. If false, the downloaded artifacts will be extracted into individual named directories within the specified path. | ||
merge-multiple: # optional, default is false | ||
# The GitHub token used to authenticate with the GitHub API. This is required when downloading artifacts from a different repository or from a different workflow run. If this is not specified, the action will attempt to download artifacts from the current repository and the current workflow run. | ||
github-token: # optional | ||
# The repository owner and the repository name joined together by "/". If github-token is specified, this is the repository that artifacts will be downloaded from. | ||
repository: # optional, default is ${{ github.repository }} | ||
# The id of the workflow run where the desired download artifact was uploaded from. If github-token is specified, this is the run that artifacts will be downloaded from. | ||
run-id: # optional, default is ${{ github.run_id }} | ||