Skip to content

bump: 4.0.2-SNAPSHOT #17

bump: 4.0.2-SNAPSHOT

bump: 4.0.2-SNAPSHOT #17

Workflow file for this run

name: Publish
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup JDK 16
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '16'
cache: 'gradle'
- name: Build
run: ./gradlew build --no-daemon
- name: Publish to Infernal Studios Maven
run: ./gradlew publish --no-daemon
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: "./build/libs/*"
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ steps.get_version.outputs.VERSION }}
docs:
runs-on: ubuntu-latest
permissions:
contents: write
if: success()
needs: [ publish ]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup JDK 16
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '16'
cache: 'gradle'
- name: Setup
id: setup
run: |
echo "::group::Generating temporary directories..."
gitdir=`mktemp -d`
moddir=`mktemp -d`
docsdir=`mktemp -d`
echo "::endgroup::"
echo "::group::Cloning repository"
echo "::debug::Cloning repository to $gitdir"
git clone "https://github.com/$GITHUB_REPOSITORY.git" "$gitdir" --depth=1 --progress --branch=main --single-branch --verbose
echo "::debug::Cloning repository to $docsdir"
git clone "https://github.com/$GITHUB_REPOSITORY.git" "$docsdir" --depth=1 --progress --branch=docs --single-branch --verbose
echo "::endgroup::"
echo "::group::Setting up cloned repositories"
cd "$gitdir"
git config advice.detachedHead false
if ! git checkout --force "$GITHUB_SHA"; then
echo "::error::Failed to checkout $GITHUB_SHA"
exit 1
fi
cd "$docsdir"
if ! git checkout --force "origin/docs"; then
echo "::error::Failed to checkout origin/docs"
exit 1
fi
rm -rfv .git README
echo "::endgroup::"
echo ""
echo "::set-output name=gitdir::$gitdir"
echo "::set-output name=moddir::$moddir"
echo "::set-output name=docsdir::$docsdir"
- name: Generate
env:
DIRECTORY: "./build/docs/javadoc"
run: |
gitdir="${{ steps.setup.outputs.gitdir }}"
moddir="${{ steps.setup.outputs.moddir }}"
docsdir="${{ steps.setup.outputs.docsdir }}"
cd "$gitdir"
echo "::endgroup::"
echo "::group::Generating documentation"
./gradlew javadoc
echo "::endgroup::"
echo "::group::Copying documentation to temporary directory"
mv -vf "$gitdir/$DIRECTORY"/* $moddir
echo "::endgroup::"
- name: Publish
run: |
gitdir="${{ steps.setup.outputs.gitdir }}"
moddir="${{ steps.setup.outputs.moddir }}"
docsdir="${{ steps.setup.outputs.docsdir }}"
gitmessage="$GITHUB_SHA
This is an automated commit by a GitHub workflow.
It contains generated documentation from the main branch of this repository.
Action: https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
moddirhash=`find "$moddir" -type f | xargs sha512sum | cut -d ' ' -f 1`
docsdirhash=`find "$docsdir" -type f | xargs sha512sum | cut -d ' ' -f 1`
if [[ "$moddirhash" != "$docsdirhash" ]]; then
echo "Documentation changed, publishing..."
cd "$moddir"
echo "::group::Preparing commit"
git init
git remote add origin "https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git"
echo "This is an automated branch. Please do not commit to or change any files in it." >> README
git add . -v
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git branch -m docs
echo "::endgroup::"
echo "::group::Committing changes"
git commit --verbose -m "$gitmessage"
echo "::endgroup::"
echo "::group::Pushing changes"
git push origin docs --force --verbose
echo "::endgroup::"
else
echo "Documentation hasn't changed, skipping publish."
fi
- name: Cleanup
run: |
gitdir="${{ steps.setup.outputs.gitdir }}"
moddir="${{ steps.setup.outputs.moddir }}"
docsdir="${{ steps.setup.outputs.docsdir }}"
cd ~
echo "::group::Removing $gitdir"
rm -rfv "$gitdir"
echo "::endgroup::"
echo "::group::Removing $moddir"
rm -rfv "$moddir"
echo "::endgroup::"
echo "::group::Removing $docsdir"
rm -rfv "$docsdir"
echo "::endgroup::"