Skip to content

Update

Update #2414

Workflow file for this run

name: Update
on:
schedule:
# Runs at 00:30, 06:30, 12:30 and 18:30 UTC every day
- cron: "30 0/6 * * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
outputs:
# Array of build data objects
# matrix:
# - mc_version: Minecraft version of the latest Paper build
# build: Build number of the latest Paper build
# channel: Release channel of the latest Paper build
# commit: Commit hash of the latest Paper build
# current_build: Paper build number of the current release of this repository
# target_version: Minecraft version of this new release of this repository
matrix: ${{ steps.data.outputs.matrix }}
steps:
- name: Install fish Shell
uses: fish-actions/[email protected]
- name: Update Build Data
id: data
shell: fish {0}
env:
fish_features: qmark-noglob
run: |
function _get_paper_build_data -a index
test -z "$index"
and set -l index -1
set -l version_group (curl -sLf https://api.papermc.io/v2/projects/paper | jq -re '.version_groups['$index']') || exit 1
curl -sLf https://api.papermc.io/v2/projects/paper/version_group/$version_group/builds | jq -rec '.builds[-1] // empty'
end
set -l build_data (_get_paper_build_data)
or set build_data (_get_paper_build_data -2) || exit 1
echo $build_data | jq -re '.channel == "experimental"' > /dev/null
and set -a build_data (_get_paper_build_data -2)
set -l tags "$(curl -sLf $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/tags?per_page=100)" || exit 1
set -l matrix
for _data in $build_data
set -l mc_version (echo $_data | jq -r '.version')
set -l base_version (string match -r '^\d+\.\d+' "$mc_version")
set -l tag_name (echo $tags | jq -re 'map(select(.name | startswith("'$base_version'")))[0] | .name // empty')
and set -l current_build (string split -f2 - $tag_name)
or set -l current_build -1
set -l current_version (string split -f1 - $tag_name)
set -l target_version (echo -e "$current_version\n$mc_version" | sort -rV | head -1)
set -a matrix (echo $_data | jq -rc '{mc_version: .version, build, channel, commit: .changes[0].commit, current_build: '$current_build', target_version: "'$target_version'"}')
end
echo "matrix=$(echo $matrix | jq -rcs '{include: .}')" >> "$GITHUB_OUTPUT"
string replace -a "=" ": " < "$GITHUB_OUTPUT"
release:
needs: update
strategy:
matrix: ${{ fromJSON(needs.update.outputs.matrix) }}
fail-fast: false
name: release (${{ format('{0}-{1}, {2}', matrix.mc_version, matrix.build, matrix.channel) }})
uses: mikelei8291/Paper-build/.github/workflows/release.yml@master
with:
mc_version: ${{ matrix.mc_version }}
build: ${{ matrix.build }}
current_build: ${{ matrix.current_build }}
commit: ${{ matrix.commit }}
prerelease: ${{ matrix.channel == 'experimental' }}
version_check: ${{ matrix.mc_version == matrix.target_version }}