Merge pull request #258 from Cosmo-Tech/JREY/fix_500_when_token_appli… #431
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: Build, Test And Upgrade SNAPSHOT if needed | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
branches: [ main ] | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build with Gradle | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: > | |
./gradlew | |
build | |
-x test | |
-x spotlessCheck | |
-x detekt | |
- name: Run unit tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew test -x spotlessCheck | |
update_snapshot_and_package: | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: | |
- build_and_test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get previous tag | |
id: previoustag | |
run: | | |
previousTag=$(git describe --tags --abbrev=0) | |
echo "tag=${previousTag}" >> "$GITHUB_OUTPUT" | |
- name: Clean Snapshot | |
uses: dev-drprasad/delete-tag-and-release@v1.1 | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
with: | |
tag_name: ${{ steps.previoustag.outputs.tag }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create tag | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
uses: EndBug/latest-tag@latest | |
with: | |
ref: ${{ steps.previoustag.outputs.tag }} | |
description: ${{ steps.previoustag.outputs.tag }} | |
- name: Create Release | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: ${{ steps.previoustag.outputs.tag }} | |
run: | | |
gh release create "$TAG" \ | |
--title="$TAG" \ | |
--generate-notes | |
- name: Set up JDK | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Setup Gradle | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Publish with Gradle | |
if: ${{ endsWith(steps.previoustag.outputs.tag, '-SNAPSHOT') }} | |
run: ./gradlew publish |