Publish Nightly Build #43
This file contains hidden or 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 Nightly Build | |
on: | |
schedule: | |
- cron: '10 7 * * *' | |
workflow_dispatch: | |
jobs: | |
should-build-change: | |
runs-on: ubuntu-latest | |
outputs: | |
repo-cache-hit: ${{ steps.cache-last-commit.outputs.cache-hit }} | |
steps: | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
- run: | | |
git rev-parse HEAD >> lastCommit | |
- name: Check New Changes | |
id: cache-last-commit | |
uses: actions/cache@v4 | |
with: | |
path: lastCommit | |
key: lastCommit-${{ hashFiles('lastCommit') }} | |
release-snapshot-job: | |
needs: should-build-change | |
if: ${{ needs.should-build-change.outputs.repo-cache-hit != 'true' || github.event_name != 'schedule' }} | |
name: Publish Snapshot | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
# Set up Java environment for the next steps | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
cache: 'gradle' | |
# Setup Gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
# Build plugin | |
- name: Build Plugin | |
run: ./gradlew build | |
# Publish to Maven repo | |
- name: Checkout Maven Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: repository | |
path: build/repository | |
- name: Deploy to Maven Repository | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2) | |
./gradlew publish | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action Bot" | |
pushd build/repository | |
git add snapshots/ | |
git commit -m "Publish ${CURRENT_VERSION} (${{github.run_number}})" | |
git push -f origin repository |