Release #415
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
# Copyright (c) 2020 anatawa12 and other contributors | |
# This file is part of fixRTM, released under GNU LGPL v3 with few exceptions | |
# See LICENSE at https://github.com/fixrtm/fixRTM for more details | |
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
release_kind: | |
type: choice | |
description: The type of release. | |
default: prerelease | |
required: true | |
options: | |
- prerelease | |
- start-rc | |
- stable | |
env: | |
SOMETHING_RELEASER_SEMVER: 1 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
environment: deployment | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PUSH_KEY }} | |
- uses: anatawa12/something-releaser@v2 | |
- run: set-git-user anatawa12-bot | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 8 | |
- name: update version name | |
id: ver_up | |
run: | | |
# set version name in properties file | |
case "$RELEASE_KIND_IN" in | |
"prerelease" ) | |
set-version "$(version-next "$(get-version)")" | |
;; | |
"start-rc" ) | |
set-version "$(version-set-channel "$(get-version)" rc)" | |
;; | |
"stable" ) | |
set-version "$(version-set-channel "$(get-version)" stable)" | |
;; | |
* ) | |
echo "invalid release kind: $RELEASE_KIND_IN" | |
exit 255 | |
;; | |
esac | |
if [ "$GITHUB_REF_NAME" != "master" ]; then | |
echo "invalid release kind: $RELEASE_KIND_IN is not allowd for $GITHUB_REF_NAME" | |
exit 255 | |
fi | |
gh-export-variable VERSION_NAME "$(get-version)" | |
gh-export-variable REQUIRED_RTM "$(file-util properties get gradle.properties rtmVersion)" | |
gh-export-variable REQUIRED_NGTLIB "$(file-util properties get gradle.properties ngtVersion)" | |
env: | |
EVENT_NAME: ${{ github.event_name }} | |
RELEASE_KIND_IN: ${{ github.event.inputs.release_kind }} | |
- name: compute version kind | |
id: compute_version_kind | |
run: | | |
case "$(version-get-channel $(get-version) 2>/dev/null || echo 'commit')" in | |
"commit" ) | |
gh-export-variable PRERELEASE true | |
gh-export-variable NIGHTLY true | |
;; | |
"beta" | "candidate" ) | |
gh-export-variable PRERELEASE true | |
gh-export-variable NIGHTLY false | |
;; | |
"stable" ) | |
gh-export-variable PRERELEASE false | |
gh-export-variable NIGHTLY false | |
;; | |
* ) | |
echo "invalid release kind" | |
exit 255 | |
;; | |
esac | |
- name: update version map | |
id: update_version_map | |
if: ${{ !fromJSON(env.PRERELEASE) }} | |
run: | | |
# update version map | |
printf "| %-11s | %-14s | %-14s |\n" \ | |
"$REQUIRED_RTM" \ | |
"$REQUIRED_NGTLIB" \ | |
"$VERSION_NAME" \ | |
>> version-map.md | |
- name: compute output informations | |
id: compute_output_informations | |
run: | | |
asset_path="./build/libs/fixRtm-$VERSION_NAME.jar" | |
gh-export-variable ASSET_PATH "$asset_path" | |
# curse info | |
if $PRERELEASE; then | |
gh-export-variable CURSE_RELEASE_TYPE "alpha" | |
else | |
gh-export-variable CURSE_RELEASE_TYPE "release" | |
fi | |
- name: commit | |
id: commit | |
if: ${{ !fromJSON(env.NIGHTLY) }} | |
run: | | |
if ! $PRERELEASE; then | |
main_changelog_file_path='CHANGELOG.md' | |
else | |
main_changelog_file_path='CHANGELOG-SNAPSHOTS.md' | |
fi | |
# first, remove empty section of changelog | |
! $PRERELEASE && ./.github/workflows/sh/prepare-changelog.sh CHANGELOG.md | |
./.github/workflows/sh/prepare-changelog.sh CHANGELOG-SNAPSHOTS.md | |
# then, get release notes for unreleased | |
unreleased_release_note_path=$(mktemp) | |
./.github/workflows/sh/get-unreleased-release-note.sh "$main_changelog_file_path" \ | |
> "$unreleased_release_note_path" | |
# after that, make unreleased -> released | |
RELEASE_DATE="$(date +%Y-%m-%d)" | |
# for release, update normal | |
! $PRERELEASE && ./.github/workflows/sh/update-changelog.sh CHANGELOG.md "$VERSION_NAME" "$RELEASE_DATE" | |
# for both prerelease and release, update -SNAPSHOTS | |
./.github/workflows/sh/update-changelog.sh CHANGELOG-SNAPSHOTS.md "$VERSION_NAME" "$RELEASE_DATE" | |
# create release note for GitHub/CurseForge release page | |
release_note_path=$(mktemp) | |
{ | |
if $PRERELEASE; then | |
echo "**This is SNAPSHOT, not a stable release. make sure this may have many bugs.**" | |
fi | |
echo "Requirements for this version: " | |
echo "RTM $REQUIRED_RTM" | |
echo "NGTLib $REQUIRED_NGTLIB" | |
echo "" | |
cat "$unreleased_release_note_path" | |
} >> "$release_note_path" | |
gh-export-variable RELEASE_NOTE_PATH "$release_note_path" | |
# commit to add updated changelog | |
git commit -am "chore: bump version to $VERSION_NAME" | |
git tag "$VERSION_NAME" | |
- name: prepare patching environment | |
uses: eskatos/gradle-command-action@v2 | |
with: | |
arguments: preparePatchingEnvironment | |
- name: apply patches | |
run: ./pm.apply-patches | |
- name: Build | |
uses: eskatos/gradle-command-action@v2 | |
with: | |
arguments: build | |
- name: push releases | |
id: push_releases | |
if: ${{ !fromJSON(env.NIGHTLY) }} | |
run: | | |
# push | |
git push | |
git push origin "$VERSION_NAME" | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: jar | |
path: ${{ env.ASSET_PATH }} | |
retention-days: 30 | |
- name: Upload To CurseForge | |
id: upload_curse | |
if: ${{ !fromJSON(env.NIGHTLY) }} | |
run: | | |
# platform version infos | |
# {"id":6756,"gameVersionTypeID":628,"name":"1.12.2","slug":"1-12-2"}, | |
# {"id":7498,"gameVersionTypeID":68441,"name":"Forge","slug":"forge"}, | |
# {"id":4458,"gameVersionTypeID":2,"name":"Java 8","slug":"java-8"}, | |
# project id for fixRTM is 365235 | |
# see https://www.curseforge.com/minecraft/mc-mods/fixrtm | |
project_id=365235 | |
publish-to-curse-forge \ | |
--file "$ASSET_PATH" \ | |
--token "$CURSE_TOKEN" \ | |
--project-id "$project_id" \ | |
--changelog-file "$RELEASE_NOTE_PATH" \ | |
--changelog-type "markdown" \ | |
--release-type "$CURSE_RELEASE_TYPE" \ | |
--game-versions "6756" \ | |
--game-versions "7498" \ | |
--game-versions "4458" \ | |
> response.json \ | |
|| { echo "POST to curse forge failed" >&2; exit 255; } | |
FILE_ID="$(jq '.id' < response.json)" | |
echo "file_id=$FILE_ID" >> $GITHUB_OUTPUT | |
env: | |
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }} | |
- name: Upload To GitHub Packages | |
id: upload_github_packagees | |
run: | | |
if $PRERELEASE; then | |
not_release=--not-release | |
fi | |
publish-to-maven \ | |
--file "$ASSET_PATH" \ | |
--group-id "com.anatawa12.fixrtm" \ | |
--artifact-id "fixrtm" \ | |
--version-name "$VERSION_NAME" \ | |
--name "fixrtm" \ | |
--user "fixrtm:$GITHUB_TOKEN" \ | |
--repository "https://maven.pkg.github.com/fixrtm/fixRTM" \ | |
--no-pom \ | |
$not_release | |
env: | |
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }} | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Create Release | |
id: create_release | |
if: ${{ !fromJSON(env.NIGHTLY) }} | |
run: |- | |
gh release create \ | |
"$VERSION_NAME" \ | |
--title "$VERSION_NAME" \ | |
--verify-tag \ | |
--notes-file "$RELEASE_NOTE_PATH" \ | |
${{ fromJSON(env.PRERELEASE) && '--prerelease' || '' }} \ | |
"$ASSET_PATH" | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Send message to discord | |
id: message_discord | |
if: ${{ !fromJSON(env.NIGHTLY) }} | |
run: | | |
{ | |
echo "fixRTM $VERSION_NAME is released!" | |
if $PRERELEASE; then | |
echo "**This is a prerelease, not a stable release. make sure this may have many bugs.**" | |
fi | |
echo "Requirements for this version:" | |
echo "RTM $REQUIRED_RTM" | |
echo "NGTLib $REQUIRED_NGTLIB" | |
echo "" | |
echo "https://www.curseforge.com/minecraft/mc-mods/fixrtm/files/$CURSE_ID" | |
echo "https://github.com/fixrtm/fixRTM/releases/tag/$VERSION_NAME" | |
} | send-discord \ | |
-i "$WEBHOOK_ID" \ | |
-t "$WEBHOOK_TOKEN" \ | |
env: | |
WEBHOOK_ID: ${{ secrets.WEBHOOK_ID }} | |
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }} | |
CURSE_ID: ${{ steps.upload_curse.outputs.file_id }} | |
- name: create next version commit releases | |
id: publish_releases | |
if: ${{ !fromJSON(env.PRERELEASE) }} | |
run: | | |
git reset --hard HEAD | |
version="$(get-version)" | |
version="$(version-next "$version")" | |
set-version "$(version-set-channel "$version" beta 0)" | |
git commit -am "chore: prepare for next version: $version" | |
git push |