Compare commits

...

8 Commits

Author SHA1 Message Date
Jikoo
c440f618c9 Bump version to 4.1.6 for release 2021-03-22 11:52:04 -04:00
Jikoo
ccc6f4b4a6 Fix CF release 2021-03-22 11:50:56 -04:00
Jikoo
ae6c3bd292 Move release location 2021-03-22 10:24:48 -04:00
Jikoo
0e3bdb8741 Convert to HTML for CF 2021-03-22 10:21:09 -04:00
Jikoo
e09e7c59c7 Fix release action 2021-03-22 09:42:52 -04:00
Jikoo
18c7916d79 Include release script 2021-03-22 09:41:36 -04:00
Jikoo
15ee6ef9a5 Fix revision number 2021-03-20 13:19:33 -04:00
Jikoo
24224e4f9d Add CurseForge release workflow 2021-03-20 13:06:33 -04:00
15 changed files with 253 additions and 67 deletions

View File

@@ -2,8 +2,6 @@ name: OpenInv CI
on:
push:
create:
types: [tag]
pull_request_target:
jobs:
@@ -51,37 +49,28 @@ jobs:
release:
name: Create Github Release
needs: [ build ]
if: github.event_name == 'create' && github.event.ref_type == 'tag'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Release Variables
run: bash ./scripts/set_release_env.sh
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Generate changelog
run: . scripts/generate_changelog.sh
- name: Create Release
id: create-release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v0.1.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
name: ${{ env.VERSIONED_NAME }}
body: ${{ env.GENERATED_CHANGELOG }}
draft: true
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./OpenInv.jar
asset_name: OpenInv.jar
asset_content_type: application/java-archive
files: ./dist/OpenInv.jar

42
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Release to CurseForge
on:
release:
types: [ released ]
jobs:
curseforge_release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set CurseForge Variables
run: . scripts/set_curseforge_env.sh
- name: Fetch Github Release Asset
uses: dsaltares/fetch-gh-release-asset@0.0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ github.event.release.id }}
file: OpenInv.jar
- name: Convert to HTML
id: convert_to_html
uses: lifepal/markdown-to-html@v1.2
with:
text: ${{ github.event.release.body }}
- name: Create CurseForge Release
uses: itsmeow/curseforge-upload@v3
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: 31432
game_endpoint: minecraft
file_path: ./OpenInv.jar
changelog: ${{ steps.convert_to_html.outputs.html }}
display_name: ${{ github.event.release.name }}
game_versions: ${{ env.CURSEFORGE_MINECRAFT_VERSIONS }}
release_type: release

View File

@@ -21,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</parent>
<artifactId>openinvapi</artifactId>

View File

@@ -21,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</parent>
<artifactId>openinvassembly</artifactId>

View File

@@ -20,7 +20,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</parent>
<artifactId>openinvinternal</artifactId>

View File

@@ -22,7 +22,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</parent>
<artifactId>openinvadapter1_16_R3</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvplugincore</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</dependency>
</dependencies>

View File

@@ -21,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</parent>
<artifactId>openinvplugincore</artifactId>
@@ -31,7 +31,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvapi</artifactId>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>

View File

@@ -84,7 +84,7 @@ public class InternalAccessor {
return "https://github.com/lishid/OpenInv/releases/tag/4.1.5";
case "v1_16_R3":
default:
return "https://github.com/lishid/OpenInv/releases";
return "https://github.com/Jikoo/OpenInv/releases";
}
}

View File

@@ -19,9 +19,9 @@
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<name>OpenInvParent</name>
<name>OpenInv</name>
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
<version>4.1.6-SNAPSHOT</version>
<version>4.1.6</version>
<packaging>pom</packaging>

View File

@@ -15,14 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# A script for generating a changelog from Git.
#
# Note that this script is designed for use in GitHub Actions, and is not
# particularly robust nor configurable. Run from project parent directory.
# Query GitHub for the username of the given email address.
# Falls through to the given author name.
lookup_email_username() {
function lookup_email_username() {
lookup=$(curl -G --data-urlencode "q=$1 in:email" https://api.github.com/search/users -H 'Accept: application/vnd.github.v3+json' | grep '"login":' | sed -e 's/^.*": "//g' -e 's/",.*$//g')
if [[ $lookup ]]; then
@@ -32,10 +30,25 @@ lookup_email_username() {
fi
}
# Get a pretty list of supported Minecraft versions
function get_minecraft_versions() {
versions=$(. ./scripts/get_spigot_versions.sh)
for version in "${versions[@]}"; do
# Append comma if variable is set, then append version
minecraft_versions="${minecraft_versions:+${minecraft_versions},}${version%%-R*}"
done
echo "${minecraft_versions}"
}
previous_tag=$(git describe --tags --abbrev=0 @^)
# Use formatted log to pull authors list
authors_raw=$(git log --pretty=format:"%ae|%an" "$(git describe --tags --abbrev=0 @^)"..@)
authors_raw=$(git log --pretty=format:"%ae|%an" "$previous_tag"..@)
readarray -t authors <<<"$authors_raw"
# Use associative array to map email to author name
declare -A author_data
for author in "${authors[@]}"; do
@@ -55,7 +68,7 @@ for author in "${authors[@]}"; do
done
# Fetch actual formatted changelog
changelog=$(git log --pretty=format:"%s (%h) - %ae" "$(git describe --tags --abbrev=0 @^)"..@)
changelog=$(git log --pretty=format:"* %s (%h) - %ae" "$previous_tag"..@)
for author_email in "${!author_data[@]}"; do
# Ignore case when matching
@@ -64,4 +77,6 @@ for author_email in "${!author_data[@]}"; do
changelog=${changelog//$author_email/${author_data[$author_email]}}
done
echo "GENERATED_CHANGELOG<<EOF${changelog}EOF" >> "$GITHUB_ENV"
minecraft_versions=$(get_minecraft_versions)
printf "## Supported Minecraft versions\n%s\n\n## Changelog\n%s" "${minecraft_versions}" "${changelog}"

View File

@@ -0,0 +1,56 @@
#!/bin/bash
#
# Copyright (C) 2011-2021 lishid. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Note that this script is designed for use in GitHub Actions, and is not
# particularly robust nor configurable. Run from project parent directory.
# Use a nameref as a cache - maven evaluation is pretty slow.
# Re-calling the script and relying on it to handle caching is way easier than passing around info.
declare -a spigot_versions
# We don't care about concatenation - either it's not null and we return or it's null and we instantiate.
# shellcheck disable=SC2199
if [[ ${spigot_versions[@]} ]]; then
for spigot_version in "${spigot_versions[@]}"; do
echo "$spigot_version"
done
return
fi
# Pull Spigot dependency information from Maven.
modules=$(mvn help:evaluate -Dexpression=project.modules -q -DforceStdout -P all -pl internal | grep -oP '(?<=<string>)(.*)(?=<\/string>)')
declare -n versions="spigot_versions"
for module in "${modules[@]}"; do
# Get number of dependencies declared in pom of specified internal module.
max_index=$(mvn help:evaluate -Dexpression=project.dependencies -q -DforceStdout -P all -pl internal/"$module" | grep -c "<dependency>")
for ((i=0; i < max_index; i++)); do
# Get artifactId of dependency.
artifact_id=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].artifactId -q -DforceStdout -P all -pl internal/"$module")
# Ensure dependency is Spigot.
if [[ "$artifact_id" == spigot ]]; then
# Get Spigot version.
spigot_version=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].version -q -DforceStdout -P all -pl internal/"$module")
versions+=("$spigot_version")
echo "$spigot_version"
break
fi
done
done

View File

@@ -15,39 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# A script for installing required Spigot versions.
#
# Note that this script is designed for use in GitHub Actions, and is
# not particularly robust nor configurable.
# In its current state, the script must be run from OpenInv's parent
# project directory and will always install BuildTools to ~/buildtools.
# Note that this script is designed for use in GitHub Actions, and is not
# particularly robust nor configurable. Run from project parent directory.
buildtools_dir=~/buildtools
buildtools=$buildtools_dir/BuildTools.jar
get_spigot_versions () {
# Get all submodules of internal module
modules=$(mvn help:evaluate -Dexpression=project.modules -q -DforceStdout -P all -pl internal | grep -oP '(?<=<string>)(.*)(?=<\/string>)')
for module in "${modules[@]}"; do
# Get number of dependencies declared in pom of specified internal module
max_index=$(mvn help:evaluate -Dexpression=project.dependencies -q -DforceStdout -P all -pl internal/"$module" | grep -c "<dependency>")
for ((i=0; i < max_index; i++)); do
# Get artifactId of dependency
artifact_id=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].artifactId -q -DforceStdout -P all -pl internal/"$module")
# Ensure dependency is spigot
if [[ "$artifact_id" == spigot ]]; then
# Get spigot version
spigot_version=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].version -q -DforceStdout -P all -pl internal/"$module")
echo "$spigot_version"
break
fi
done
done
}
get_buildtools () {
if [[ -d $buildtools_dir && -f $buildtools ]]; then
return
@@ -57,7 +30,7 @@ get_buildtools () {
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O $buildtools
}
versions=$(get_spigot_versions)
versions=$(. ./scripts/get_spigot_versions.sh)
echo Found Spigot dependencies: "$versions"
for version in "${versions[@]}"; do
@@ -66,7 +39,7 @@ for version in "${versions[@]}"; do
mvn dependency:get -Dartifact=org.spigotmc:spigot:"$version" -q -o || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo Installing missing Spigot version "$version"
revision=$(echo "$version" | grep -oP '(\d+\.\d+(\.\d+)?)(?=-R[0-9\.]+-SNAPSHOT)')
revision=${version%%-R*}
get_buildtools
java -jar $buildtools -rev "$revision"
else

View File

@@ -0,0 +1,42 @@
#!/bin/bash
#
# Copyright (C) 2011-2021 lishid. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Note that this script is designed for use in GitHub Actions, and is not
# particularly robust nor configurable. Run from project parent directory.
# Parse Spigot dependency information into major Minecraft versions
function get_curseforge_minecraft_versions() {
versions=$(. ./scripts/get_spigot_versions.sh)
for version in "${versions[@]}"; do
# Parse Minecraft major version
version="${version%[.-]"${version#*.*[.-]}"}"
# Skip already listed versions
if [[ "$minecraft_versions" =~ "$version"($|,) ]]; then
continue
fi
# Append comma if variable is set, then append version
minecraft_versions="${minecraft_versions:+${minecraft_versions},}Minecraft ${version}"
done
echo "${minecraft_versions}"
}
minecraft_versions=$(get_curseforge_minecraft_versions)
echo "CURSEFORGE_MINECRAFT_VERSIONS=$minecraft_versions" >> "$GITHUB_ENV"

View File

@@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (C) 2011-2021 lishid. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Note that this script is designed for use in GitHub Actions, and is not
# particularly robust nor configurable. Run from project parent directory.
# Get a pretty string of the project's name and version
# Disable SC warning about variable expansion for this function - those are Maven variables.
# shellcheck disable=SC2016
function get_versioned_name() {
mvn -q -Dexec.executable=echo -Dexec.args='${project.name} ${project.version}' --non-recursive exec:exec
}
# Set GitHub environmental variables
echo "VERSIONED_NAME=$(get_versioned_name)" >> "$GITHUB_ENV"
changelog="$(. ./scripts/generate_changelog.sh)"
printf "GENERATED_CHANGELOG<<EOF\n%s\nEOF\n" "$changelog" >> "$GITHUB_ENV"

37
scripts/tag_release.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
#
# Copyright (C) 2011-2021 lishid. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if [[ ! $1 ]]; then
echo "Please provide a version string."
return
fi
version="$1"
snapshot="${version%.*}.$((${version##*.} + 1))-SNAPSHOT"
mvn versions:set -DnewVersion="$version"
git add .
git commit -S -m "Bump version to $version for release"
git tag -s "$version" -m "Release $version"
mvn clean package -am -P all
mvn versions:set -DnewVersion="$snapshot"
git add .
git commit -S -m "Bump version to $snapshot for development"