diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml new file mode 100644 index 0000000000..b61f0faf7f --- /dev/null +++ b/.github/workflows/crowdin.yml @@ -0,0 +1,48 @@ +name: Upload lang keys to Crowdin + +on: + workflow_dispatch: + push: + branches: + - '1.[0-9]+' + - '1.[0-9]+.[0-9]+' + paths: + - 'src/main/resources/assets/vampirism/lang/en_us.json' + - 'src/main/resources/assets/vampirismguide/lang/en_us.json' + +jobs: + upload-translations: + environment: Testing + runs-on: ubuntu-latest + + 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: | + version=$(./gradlew crowdinBranch -q) + if [[ $version =~ ^1\.[0-9]+$ ]]; then + echo "Crowdin branch: $version" + echo "crowdin_branch=$version" >> $GITHUB_OUTPUT + else + echo "Invalid version: $version" + exit 1 + fi + - name: Upload translation keys + uses: crowdin/github-action@v1 + with: + crowdin_branch_name: ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} + env: + CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} + - name: Install Crowdin CLI + run: npm i -g @crowdin/cli + - name: Pre-translate + run: crowdin pre-translate -b ${{ steps.get_crowdin_branch.outputs.crowdin_branch }} --translate-with-perfect-match-only --translate-untranslated-only --method=tm + env: + CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }} diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 7af61c78cd..59a3d10bd0 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,9 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Java JDK - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'adopt' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..1938a64252 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,101 @@ +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 | awk -F ': ' '{print $2}') + echo "crowdin_branch=$version" >> $GITHUB_OUTPUT + + 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 -PMAVEN_URL=${{ secrets.MAVEN_URL }} -PMAVEN_USER=${{ secrets.MAVEN_USER }} -PMAVEN_TOKEN=${{ secrets.MAVEN_TOKEN }} -PCURSEFORGE_API=${{ secrets.CURSEFORGE_API }} -PMODRINTH_API=${{ secrets.MODRINTH_API }} -PCHANGELOG=${{ github.event.inputs.changelog }} -P${{ needs.determine-environment.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index a7ba86d4b4..b9b8e62510 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest if: github.ref_name == github.event.repository.default_branch steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Upload supporters uses: wei/curl@v1 with: diff --git a/build.gradle b/build.gradle index 1ba52b1c9f..d51f472d14 100755 --- a/build.gradle +++ b/build.gradle @@ -86,10 +86,7 @@ tasks.named('processResources', ProcessResources).configure { } tasks.named('jar', Jar).configure { - dependsOn 'crowdin' - includeEmptyDirs = false - from sourceSets.main.output.classesDirs from sourceSets.api.output.classesDirs from sourceSets.lib.output.classesDirs diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000000..0dcf85d05f --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,19 @@ +project_id: "113663" +api_token_env: CROWDIN_KEY +base_path: "." +base_url: "https://api.crowdin.com" + +preserve_hierarchy: true + +files: [ + { + source: "src/main/resources/assets/vampirism/lang/en_us.json", + translation: "src/main/resources/assets/vampirism/lang/%locale_with_underscore%.json", + dest: "main_translations.json", + }, + { + source: "src/main/resources/assets/vampirismguide/lang/en_us.json", + translation: "src/main/resources/assets/vampirismguide/lang/%locale_with_underscore%.json", + dest: "guide.json", + } +] \ No newline at end of file diff --git a/gradle/crowdin.gradle b/gradle/crowdin.gradle index 2cb0c5e425..433baded5e 100644 --- a/gradle/crowdin.gradle +++ b/gradle/crowdin.gradle @@ -1,43 +1,5 @@ -tasks.register('downloadCrowdin') { - ext { - output = file('build/crowdin_raw.zip') - update = file('build/crowdin.json') - id = 'vampirism' - } - outputs.upToDateWhen { false } - onlyIf { - project.hasProperty('VAMPIRISM_CROWDIN_KEY') && !project.gradle.startParameter.isOffline() - } +tasks.register('crowdinBranch') { doLast { - download { - src "https://api.crowdin.com/api/project/${id}/export?key=${project.VAMPIRISM_CROWDIN_KEY}&export_translated_only&json" - dest update - overwrite true - } - if (!update.text.contains('success')) { - throw new RuntimeException("Crowdin export failed, see ${update} for more info") - } - download { - src "https://api.crowdin.com/api/project/${id}/download/all.zip?key=${project.VAMPIRISM_CROWDIN_KEY}" - dest output - overwrite true - } - } -} - -tasks.register('crowdin', Copy) { - dependsOn downloadCrowdin - onlyIf { - !downloadCrowdin.state.skipped - } - destinationDir = file('build/translations') - from(zipTree(downloadCrowdin.output)) { - filter { String line -> - line.indexOf("\"\"") != -1 ? null : line //Filter empty translations - } - filteringCharset = 'UTF-8' - exclude { it.isDirectory() } - rename { it.toLowerCase() }//Minecraft needs it lowercase. - exclude '**/*.lang' //Pre-1.13 format + print("${project.main_version}.${project.major_version}") } } \ No newline at end of file diff --git a/gradle/deploy.gradle b/gradle/deploy.gradle index e75ace22cd..bd9b89029f 100755 --- a/gradle/deploy.gradle +++ b/gradle/deploy.gradle @@ -8,6 +8,7 @@ curseforge { project { id = "233029" + changelog = findProperty("CHANGELOG") ?:"" if (project.type == "beta") { releaseType = 'beta' //changelog = new File("resources/changelog/${project.version}.txt").text @@ -15,7 +16,7 @@ curseforge { releaseType = 'release' } else { releaseType = 'alpha' - changelog = "This version should not be used in your 'productive' world. It contains the latest features, but also the latest bugs.\n Probably not all features are finished.\n To see what might have changed visit our Github page and browse the latest commits." + changelog = !(findProperty("CHANGELOG") ?: "").toString().isEmpty() ? getProperty("CHANGELOG") : "This version should not be used in your 'productive' world. It contains the latest features, but also the latest bugs.\n Probably not all features are finished.\n To see what might have changed visit our Github page and browse the latest commits." } addGameVersion project.minecraft_version @@ -108,9 +109,9 @@ publishing { // Make sure it runs after build! modrinth { + changelog = findProperty("CHANGELOG") ?:"" if (project.type == "beta") { versionType = 'beta' - //changelog = new File("resources/changelog/${project.version}.txt").text } else if (project.type == "release") { versionType = 'release' } else {