From 761c1856e795d3669f63b8af0d24222767c982fa Mon Sep 17 00:00:00 2001 From: altrisi Date: Tue, 29 Dec 2020 17:11:56 +0100 Subject: [PATCH 1/7] Add Publish Release Action After over 40 iterations, it's here! --- .github/workflows/publish-release.yml | 183 ++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..c33ab164 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,183 @@ +name: Publish Release + +on: + release: + types: [published] +jobs: + Get-Properties: + runs-on: ubuntu-latest + outputs: + release-type: ${{ steps.type.outputs.release-type }} + carpet-version: ${{ steps.properties.outputs.mod_version }} + minecraft-version: ${{ steps.properties.outputs.minecraft_version }} + # extra-branch: ${{ steps.properties.outputs.release-extra-branch }} Not needed anymore + matrix-exclude-branch: ${{ steps.processmatrix.outputs.matrix-to-exclude }} + extra-branch-name: ${{ steps.properties.outputs.release-extra-branch-name }} + extra-branch-curse-version: ${{ steps.properties.outputs.release-extra-curse-version }} + steps: + - name: Checkout the sources + uses: actions/checkout@v2 + - name: Determine release type + id: type + run: | + if ${{ github.event.release.prerelease }}; then + echo "::set-output name=release-type::beta" + else + echo "::set-output name=release-type::release" + fi + - name: Read relevant fields from gradle.properties + id: properties + run: | # From christian-draeger/read-properties, using the action makes it extremely messy until christian-draeger/read-properties#2 + path='./gradle.properties' + for property in mod_version minecraft_version release-extra-branch release-extra-branch-name release-extra-curse-version + do + result=$(sed -n "/^[[:space:]]*$property[[:space:]]*=[[:space:]]*/s/^[[:space:]]*$property[[:space:]]*=[[:space:]]*//p" "$path") + echo "$property: $result" + echo ::set-output name=$property::"$result" + done + - name: Process property for matrix + id: processmatrix + run: | + if ! ${{ steps.properties.outputs.release-extra-branch }}; then + echo "::set-output name=matrix-to-exclude::Snapshots" + fi + Build-And-Publish: + runs-on: ubuntu-latest + needs: [Get-Properties] + strategy: + matrix: + branch: [Release, Snapshots] + exclude: + - branch: ${{ needs.Get-Properties.outputs.matrix-exclude-branch }} + steps: + - name: Get info from branch to run + id: getbranchinfo + run: | + if ${{ matrix.branch == 'Snapshots'}}; then + echo "::set-output name=branchname::${{ needs.Get-Properties.outputs.extra-branch-name }}" + echo "::set-output name=version::${{ needs.Get-Properties.outputs.extra-branch-curse-version }}" + else + echo "::set-output name=version::${{ needs.Get-Properties.outputs.minecraft-version }}" + fi + - name: Checkout the sources + uses: actions/checkout@v2 + with: + ref: ${{ steps.getbranchinfo.outputs.branchname }} + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Grant execute permission to gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Find correct JAR + id: findjar + run: | + output="$(find build/libs/ ! -name "*-dev.jar" ! -name "*-sources.jar" -type f -printf "%f\n")" + echo "::set-output name=jarname::$output" + - name: Save build artifacts in the action + uses: actions/upload-artifact@v2 + with: + name: Artifacts for ${{ matrix.branch }} + path: build/libs + - name: Upload to the Github release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: build/libs/${{ steps.findjar.outputs.jarname }} + asset_name: ${{ steps.findjar.outputs.jarname }} + asset_content_type: application/java-archive + - name: Upload to Curseforge + uses: itsmeow/curseforge-upload@v3 + with: + token: ${{ secrets.CF_API_TOKEN }} + project_id: 349239 + game_endpoint: minecraft + file_path: build/libs/${{ steps.findjar.outputs.jarname }} + changelog_type: markdown + changelog: ${{ github.event.release.body }} + display_name: Carpet Mod v${{ needs.Get-Properties.outputs.carpet-version }} for ${{ steps.getbranchinfo.outputs.version }} + game_versions: 7499,4458,${{ steps.getbranchinfo.outputs.version }} #Fabric,Java 8,[version for the branch] + release_type: ${{ needs.Get-Properties.outputs.release-type }} + Merge-Scarpet-Docs: + runs-on: ubuntu-latest + steps: + - name: Checkout the sources + uses: actions/checkout@v2 + with: + ref: master + - name: Merge docs + run: | + ./mergedoc.sh + - name: Commit merged docs + continue-on-error: true + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git commit -am "Merge docs for '${{ github.event.release.name }}'" || exit 0 + git push + Update-Rules-Wiki: + runs-on: ubuntu-latest + steps: + - name: Checkout Carpet sources + uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Replace fabric.mod.json + run: | + cd src/main/resources + rm fabric.mod.json + echo ' + { + "schemaVersion": 1, + "id": "carpet", + "version": "1.4.11", + "entrypoints": { + "preLaunch": [ "carpet.utils.RulePrinter" ] + } + }' > fabric.mod.json + cd ../../../ + - name: Run solution + run: | + chmod +x gradlew + ./gradlew runServer > settings-toProccess.txt + - name: Checkout wiki + uses: actions/checkout@v2 + with: + repository: ${{github.repository}}.wiki + path: wiki + - name: Proccess Gradle log into a pretty wiki page + run: | + from1="# Carpet"; + File=settings-toProccess.txt + if grep -q "Deprecated Gradle features" "$File"; then # Happens after update to Gradle 6 + to2="Deprecated Gradle features"; + else + to2="BUILD SUCCESSFUL" + fi + a="$(cat settings-toProccess.txt)"; a="$(echo "${a#*"$from1"}")"; echo "$from1${a%%"$to2"*}" > wiki/Current-Available-Settings.md + - name: Commit updated wiki page + continue-on-error: true + run: | + cd wiki + git config --global user.name 'github-actions-bot' # Releases don't have valid commiter info :( + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git commit -am "Update wiki for '${{ github.event.release.name }}'" || exit 0 + git push From 5aa9c4c4b257f063667c75d0078eff6edf5e7ec4 Mon Sep 17 00:00:00 2001 From: altrisi Date: Tue, 29 Dec 2020 17:12:24 +0100 Subject: [PATCH 2/7] Delete merge-docs.yml --- .github/workflows/merge-docs.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 .github/workflows/merge-docs.yml diff --git a/.github/workflows/merge-docs.yml b/.github/workflows/merge-docs.yml deleted file mode 100644 index 11dccee0..00000000 --- a/.github/workflows/merge-docs.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Merge docs -on: - push: - branches: - - master - paths: - - "docs/**" -jobs: - Scarpet: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Merge docs - run: ./mergedoc.sh - - name: Commit merged docs - continue-on-error: true - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git commit -am "Merge docs for '${{ github.event.head_commit.message }}'" - git push From 1d0301e44c04f09aee743eac0ac0955fe1193b93 Mon Sep 17 00:00:00 2001 From: altrisi Date: Tue, 29 Dec 2020 17:12:39 +0100 Subject: [PATCH 3/7] Delete rules-to-wiki.yml --- .github/workflows/rules-to-wiki.yml | 64 ----------------------------- 1 file changed, 64 deletions(-) delete mode 100644 .github/workflows/rules-to-wiki.yml diff --git a/.github/workflows/rules-to-wiki.yml b/.github/workflows/rules-to-wiki.yml deleted file mode 100644 index 76e25bf3..00000000 --- a/.github/workflows/rules-to-wiki.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Update wiki -on: - push: - branches: - - master - paths: - - "src/main/java/carpet/CarpetSettings.java" -jobs: - Rules: - runs-on: ubuntu-latest - steps: - - name: Checkout Carpet sources - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - name: Replace fabric.mod.json - run: | - cd src/main/resources - rm fabric.mod.json - echo ' - { - "schemaVersion": 1, - "id": "carpet", - "version": "1.4.11", - "entrypoints": { - "preLaunch": [ "carpet.utils.RulePrinter" ] - } - }' > fabric.mod.json - cd ../../../ - - name: Run solution - run: | - chmod +x gradlew - ./gradlew runServer > settings-toProccess.txt - - name: Checkout wiki - uses: actions/checkout@v2 - with: - repository: ${{github.repository}}.wiki - path: wiki - - name: Proccess Gradle log into a pretty wiki page - run: | - from1="# Carpet"; - File=settings-toProccess.txt - if grep -q "Deprecated Gradle features" "$File"; then # Happens after update to Gradle 6 - to2="Deprecated Gradle features"; - else - to2="BUILD SUCCESSFUL" - fi - a="$(cat settings-toProccess.txt)"; a="$(echo "${a#*"$from1"}")"; echo "$from1${a%%"$to2"*}" > wiki/Current-Available-Settings.md - - name: Commit updated wiki page - continue-on-error: true - run: | - cd wiki - git config --global user.name '${{ github.event.pusher.name }}' # Looks better than "github-actions-bot" - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git commit -am "Update wiki for '${{ github.event.head_commit.message }}'" - git push From 6e19c8a22454a12eb9b7c8659c2cb2e41c2ad935 Mon Sep 17 00:00:00 2001 From: altrisi Date: Tue, 29 Dec 2020 20:46:02 +0100 Subject: [PATCH 4/7] Add gradle.properties entries --- gradle.properties | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gradle.properties b/gradle.properties index 9551a36d..aacc1bc9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,6 +13,16 @@ org.gradle.jvmargs=-Xmx1G maven_group = carpet archives_base_name = fabric-carpet +# Release Action properties for Snapshots and Curseforge + # Whether or not to build another branch on release + release-extra-branch = true + # The name of the second branch to release + release-extra-branch-name = 1.17 + # The "name" or id of the Curseforge version for the secondary branch + # This is needed because CF uses too vague names for snapshots + # Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN] + release-extra-curse-version = 1.17 + # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api #fabric_version=0.3.0-pre+build.166 From 7e358778250a80fb3c931ea281851b130cf12cbc Mon Sep 17 00:00:00 2001 From: altrisi Date: Sat, 2 Jan 2021 13:23:29 +0100 Subject: [PATCH 5/7] Save maven artifacts in the action So they don't have to be built locally again --- .github/workflows/publish-release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index c33ab164..ec2feea0 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -108,6 +108,13 @@ jobs: display_name: Carpet Mod v${{ needs.Get-Properties.outputs.carpet-version }} for ${{ steps.getbranchinfo.outputs.version }} game_versions: 7499,4458,${{ steps.getbranchinfo.outputs.version }} #Fabric,Java 8,[version for the branch] release_type: ${{ needs.Get-Properties.outputs.release-type }} + - name: Ask Gradle to publish + run: ./gradlew publish + - name: Save publish folder in action's artifacts + uses: actions/upload-artifact@v2 + with: + name: Maven publishing artifacts for ${{ matrix.branch }} + path: publish/carpet/fabric-carpet/ Merge-Scarpet-Docs: runs-on: ubuntu-latest steps: From 2e64ba9527020239eea904cae15f3b7b7cfbb660 Mon Sep 17 00:00:00 2001 From: altrisi Date: Thu, 14 Jan 2021 04:25:40 +0100 Subject: [PATCH 6/7] Allow custom CF versions in main branch --- .github/workflows/publish-release.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index ec2feea0..3392784f 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,7 +10,7 @@ jobs: release-type: ${{ steps.type.outputs.release-type }} carpet-version: ${{ steps.properties.outputs.mod_version }} minecraft-version: ${{ steps.properties.outputs.minecraft_version }} - # extra-branch: ${{ steps.properties.outputs.release-extra-branch }} Not needed anymore + curse-versions: ${{ steps.properties.outputs.release-curse-versions }} matrix-exclude-branch: ${{ steps.processmatrix.outputs.matrix-to-exclude }} extra-branch-name: ${{ steps.properties.outputs.release-extra-branch-name }} extra-branch-curse-version: ${{ steps.properties.outputs.release-extra-curse-version }} @@ -29,7 +29,7 @@ jobs: id: properties run: | # From christian-draeger/read-properties, using the action makes it extremely messy until christian-draeger/read-properties#2 path='./gradle.properties' - for property in mod_version minecraft_version release-extra-branch release-extra-branch-name release-extra-curse-version + for property in mod_version minecraft_version release-curse-versions release-extra-branch release-extra-branch-name release-extra-curse-version do result=$(sed -n "/^[[:space:]]*$property[[:space:]]*=[[:space:]]*/s/^[[:space:]]*$property[[:space:]]*=[[:space:]]*//p" "$path") echo "$property: $result" @@ -56,8 +56,10 @@ jobs: if ${{ matrix.branch == 'Snapshots'}}; then echo "::set-output name=branchname::${{ needs.Get-Properties.outputs.extra-branch-name }}" echo "::set-output name=version::${{ needs.Get-Properties.outputs.extra-branch-curse-version }}" + echo "::set-output name=curse-versions::${{ needs.Get-Properties.outputs.extra-branch-curse-version }}" else echo "::set-output name=version::${{ needs.Get-Properties.outputs.minecraft-version }}" + echo "::set-output name=curse-versions::${{ needs.Get-Properties.outputs.curse-versions }}" fi - name: Checkout the sources uses: actions/checkout@v2 @@ -106,11 +108,11 @@ jobs: changelog_type: markdown changelog: ${{ github.event.release.body }} display_name: Carpet Mod v${{ needs.Get-Properties.outputs.carpet-version }} for ${{ steps.getbranchinfo.outputs.version }} - game_versions: 7499,4458,${{ steps.getbranchinfo.outputs.version }} #Fabric,Java 8,[version for the branch] + game_versions: 7499,4458,${{ steps.getbranchinfo.outputs.curse-versions }} #Fabric,Java 8,[version (s) for the branch] release_type: ${{ needs.Get-Properties.outputs.release-type }} - name: Ask Gradle to publish run: ./gradlew publish - - name: Save publish folder in action's artifacts + - name: Save publish folder in action's artifacts # Remove when automated uses: actions/upload-artifact@v2 with: name: Maven publishing artifacts for ${{ matrix.branch }} From 8bd6bd8343a00f07f167fed164319574a82a4f3c Mon Sep 17 00:00:00 2001 From: altrisi Date: Thu, 14 Jan 2021 04:28:52 +0100 Subject: [PATCH 7/7] Add `release-curse-versions` field to properties --- gradle.properties | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index aacc1bc9..54c4ef7c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,11 @@ org.gradle.jvmargs=-Xmx1G maven_group = carpet archives_base_name = fabric-carpet -# Release Action properties for Snapshots and Curseforge +# Release Action properties for Curseforge and Snapshots + # The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5) + # This is needed because CF uses too vague names for prereleases and release candidates + # Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN] + release-curse-versions = 1.16.3,1.16.4 # Whether or not to build another branch on release release-extra-branch = true # The name of the second branch to release