Update publish.yml #42
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: insert version | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.INSERT_VERSION }} | |
- name: validate gradle wrapper | |
uses: gradle/wrapper-validation-action@v3 | |
- name: setup jdk | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'microsoft' | |
- name: make gradle wrapper executable | |
if: runner.os != 'Windows' | |
run: chmod +x ./gradlew | |
- name: build | |
run: ./gradlew build | |
env: | |
PACKAGES_USER: ${{ secrets.PACKAGES_USER }} | |
PACKAGES_KEY: ${{ secrets.PACKAGES_KEY }} | |
- name: Read VERSION file | |
id: getversion | |
run: echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT" | |
- name: Check version length | |
id: check-version-length | |
run: | | |
if [ ${#version} -gt 10 ]; then | |
echo "failure=true" >> "$GITHUB_OUTPUT" | |
gh run cancel ${{ github.run_id }} | |
exit 1 | |
fi | |
- name: Find and Replace | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "INSERT VERSION" | |
replace: "${{ steps.getversion.outputs.version }}" | |
include: "src/**" | |
regex: false | |
- name: Commit changes | |
if: steps.check-version-length.outputs.failure != 'true' | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
id: auto-commit-action | |
with: | |
commit_message: "Insert Version ${{ steps.getversion.outputs.version }}" |