Carpet Extra 1.4.158 for Minecraft 1.21.2 and 1.21.3 #32
Workflow file for this run
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 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 }} | |
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 }} | |
steps: | |
- name: Checkout the sources | |
uses: actions/checkout@v4 | |
- name: Determine release type | |
id: type | |
run: | | |
if ${{ github.event.release.prerelease }}; then | |
echo "release-type=beta" >> $GITHUB_OUTPUT | |
else | |
echo "release-type=release" >> $GITHUB_OUTPUT | |
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-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" | |
echo "$property=$result" >> $GITHUB_OUTPUT | |
done | |
- name: Process property for matrix | |
id: processmatrix | |
run: | | |
if ! ${{ steps.properties.outputs.release-extra-branch }}; then | |
echo "matrix-to-exclude=Snapshots" >> $GITHUB_OUTPUT | |
fi | |
- uses: actions/github-script@v7 | |
env: | |
READ_VERSION: ${{ steps.properties.outputs.mod_version }} | |
with: | |
script: | | |
const { READ_VERSION } = process.env; | |
console.log('Read version is: ' + READ_VERSION); | |
let releases = (await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
})).data; | |
console.log('Previous release was: ' + releases[1].name); | |
for (let release of releases.slice(1)) { | |
if (release.name.includes(READ_VERSION)) | |
core.setFailed('Version number is the same as a previous release!') | |
} | |
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 "branchname=${{ needs.Get-Properties.outputs.extra-branch-name }}" >> $GITHUB_OUTPUT | |
echo "version=${{ needs.Get-Properties.outputs.extra-branch-curse-version }}" >> $GITHUB_OUTPUT | |
echo "curse-versions=${{ needs.Get-Properties.outputs.extra-branch-curse-version }}" >> $GITHUB_OUTPUT | |
else | |
echo "version=${{ needs.Get-Properties.outputs.minecraft-version }}" >> $GITHUB_OUTPUT | |
echo "curse-versions=${{ needs.Get-Properties.outputs.curse-versions }}" >> $GITHUB_OUTPUT | |
fi | |
- name: Checkout the sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.getbranchinfo.outputs.branchname }} | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: '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 "jarname=$output" >> $GITHUB_OUTPUT | |
- name: Save build artifacts in the action | |
uses: actions/upload-artifact@v4 | |
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: 349240 | |
game_endpoint: minecraft | |
file_path: build/libs/${{ steps.findjar.outputs.jarname }} | |
changelog_type: markdown | |
changelog: ${{ github.event.release.body }} | |
display_name: Carpet Extra v${{ needs.Get-Properties.outputs.carpet-version }} for ${{ steps.getbranchinfo.outputs.version }} | |
game_versions: 7499,8326,${{ steps.getbranchinfo.outputs.curse-versions }} #Fabric,Java 17,[version (s) for the branch] | |
relations: carpet:requiredDependency | |
release_type: ${{ needs.Get-Properties.outputs.release-type }} | |
Update-Rules-to-Readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Carpet extra sources | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'gradle' | |
- name: Update README page | |
run: | | |
chmod +x gradlew | |
./gradlew runServer --args="-- -carpetDumpRules -dumpFilter=extras -dumpPath ../rules.md" | |
cat README-header.md rules.md > README.md | |
- name: Commit updated Readme page | |
continue-on-error: true | |
run: | | |
git add README.md | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git commit -m "Update Readme for '${{ github.event.release.name }}'" || exit 0 | |
git push |