Publish #13
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 | |
on: | |
push: | |
tags: | |
- v* | |
workflow_dispatch: | |
inputs: | |
versionType: | |
description: 'Version Type' | |
required: true | |
default: 'alpha' | |
type: choice | |
options: | |
- alpha | |
- beta | |
- release | |
additionalVersionInfo: | |
description: 'Additional Version Info. Only relevant for beta versions.' | |
required: false | |
default: '' | |
type: string | |
changelog: | |
description: 'Changelog added to Curseforge and Modrinth' | |
required: false | |
default: '' | |
type: string | |
permissions: | |
contents: read | |
jobs: | |
determine-environment: | |
runs-on: ubuntu-latest | |
outputs: | |
environment: ${{ steps.get_environment.outputs.environment }} | |
version: ${{ steps.get_environment.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Determine Environment | |
id: get_environment | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
if [[ "${{ github.event.inputs.versionType }}" == 'alpha' ]]; then | |
echo "environment=Testing" >> $GITHUB_OUTPUT | |
echo "version=alpha" >> $GITHUB_OUTPUT | |
elif [[ "${{ github.event.inputs.versionType }}" == 'beta' ]]; then | |
echo "environment=Testing" >> $GITHUB_OUTPUT | |
echo "version=beta=${{ github.event.inputs.additionalVersionInfo }}" >> $GITHUB_OUTPUT | |
elif [[ "${{ github.event.inputs.versionType }}" == 'release' ]]; then | |
echo "environment=Release" >> $GITHUB_OUTPUT | |
echo "version=release" >> $GITHUB_OUTPUT | |
fi | |
elif [[ ${{ github.event.ref }} =~ refs\/tags\/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))? ]]; then | |
echo "environment=Release" >> $GITHUB_OUTPUT | |
echo "version=release" >> $GITHUB_OUTPUT | |
fi | |
determine-crowdin-branch: | |
runs-on: ubuntu-latest | |
outputs: | |
crowdin_branch: ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: 'gradle' | |
- name: Determine Crowdin branch | |
id: get_crowdin_branch | |
run: | | |
output=$(./gradlew crowdinBranch) | |
version=$(echo "$output" | grep -oP 'Crowdin branch: \K\d+\.\d+') | |
if [[ $version =~ ^1\.[0-9]+$ ]]; then | |
echo "Crowdin branch: $version" | |
echo "crowdin_branch=$version" >> $GITHUB_OUTPUT | |
else | |
echo "Invalid version: $version" | |
exit 1 | |
fi | |
publish: | |
runs-on: ubuntu-latest | |
needs: [determine-crowdin-branch, determine-environment] | |
environment: ${{ needs.determine-environment.outputs.environment }} | |
if: needs.determine-environment.outputs.version != '' && needs.determine-environment.outputs.environment != '' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: 'gradle' | |
- name: Install Crowdin CLI | |
run: npm i -g @crowdin/cli | |
- name: Download translations | |
run: crowdin download -b ${{ needs.determine-crowdin-branch.outputs.crowdin_branch }} | |
env: | |
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} | |
- name: Publish | |
uses: gradle/gradle-build-action@v2.7.0 | |
with: | |
arguments: publishAll -Pmaxanier_maven_url=${{ secrets.MAVEN_URL }} -Pmaxanier_maven_alias=${{ secrets.MAVEN_USER }} -Pmaxanier_maven_token=${{ secrets.MAVEN_TOKEN }} -PCURSEFORGE_API=${{ secrets.CURSEFORGE_API }} -PMODRINTH_API=${{ secrets.MODRINTH_API }} -P${{ needs.determine-environment.outputs.version }} |