fix(gh-actions): forgot needs #3
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
name: Publish Api | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
getVersion: | |
runs-on: ubuntu-22.04 | |
outputs: | |
tag: ${{ steps.vars.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: vars | |
run: echo "tag=`cat gradle.properties | grep apiVersion | cut -d'=' -f2`" >> $GITHUB_OUTPUT | |
planner: | |
needs: getVersion | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Mark release job as 'to be run' | |
id: do_release | |
run: | | |
TAG=${{ needs.getVersion.outputs.tag }} | |
if git show-ref --tags --verify --quiet "refs/tags/api-${TAG}"; then | |
echo "Api version ${TAG} exists, no release to run" | |
echo "do_release=false" >> $GITHUB_OUTPUT | |
else | |
echo "Api version ${TAG} does not exists, a release will be trigger" | |
echo "do_release=true" >> $GITHUB_OUTPUT | |
release: | |
runs-on: ubuntu-22.04 | |
needs: planner | |
if: needs.planner.outputs.do_release == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: corretto | |
java-version: 17 | |
- name: Cleanup Gradle Cache | |
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. | |
# Restoring these files from a GitHub Actions cache might cause problems for future builds. | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties | |
- name: Setup Gradle Wrapper Cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-library-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
- name: Publish Gradle Package | |
run: ./gradlew :api:build -x test :api:publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
# MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: api-${{ needs.getVersion.outputs.tag }} | |
make_latest: false | |
files: | | |
api/build/libs/*.jar |