Skip to content

Streamline SyntaxWraps (#691) #446

Streamline SyntaxWraps (#691)

Streamline SyntaxWraps (#691) #446

# 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 Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches:
- "main"
env:
RELEASE_TAG: "snapshot"
RELEASE_TITLE: "Latest snapshot build"
RELEASE_NOTE: "Snapshot build from the latest commit on main"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # to create/update tags and upload artifacts
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
# https://github.com/actions/setup-java
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: corretto
# Configure Gradle for optimal use in GitHub Actions,
# including caching of downloaded dependencies.
# https://github.com/gradle/actions/blob/main/setup-gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Run build
- name: Build with Gradle Wrapper
run: ./gradlew build
# Upload an artifact release for later jobs to consume
- name: Upload distribution
uses: actions/upload-artifact@v4
with:
name: distribution-artifacts
path: sdk/build/distributions/
if-no-files-found: error
# Maintain snapshot tag
- name: Tag snapshot release
if: ${{ vars.PUBLISH_RELEASE == 'true' }}
run: |
# Update the release tag to point to the current commit.
git tag -f "$RELEASE_TAG"
git push origin -f "$RELEASE_TAG"
publish-release:
if: ${{ vars.PUBLISH_RELEASE == 'true' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # to create a release
steps:
- name: Download distribution
uses: actions/download-artifact@v4
with:
name: distribution-artifacts
path: distributions
- name: Upload snapshot release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Delete the existing release if it exists.
EXISTING_RELEASE=$(gh release list --repo ${{ github.repository }} --json tagName --jq ".[] | select(.tagName==\"$RELEASE_TAG\")")
if [ -n "$EXISTING_RELEASE" ]; then
gh release delete --repo ${{ github.repository }} \
"$RELEASE_TAG" \
--yes
fi
# Create the release and upload the distribution files (this will include a zip and a tarball).
gh release create --repo ${{ github.repository }} \
"$RELEASE_TAG" \
--title "$RELEASE_TITLE" \
--notes "$RELEASE_NOTE" \
--prerelease \
--verify-tag \
distributions/*
dependency-submission:
if: ${{ vars.SUBMIT_DEPENDENCIES == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: corretto
# Generates and submits a dependency graph, enabling Dependabot Alerts.
# https://github.com/gradle/actions/blob/main/dependency-submission
# https://github.com/gradle/github-dependency-submission-demo
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v4