From 39b9d261b92d4864e518c5b388a9ea131a9c6aeb Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Fri, 12 Nov 2021 19:06:21 +0200 Subject: [PATCH] embed build script version in its file; add zip-packages job to CI --- .github/scripts/update-version.sh | 8 ++++ .github/workflows/repository-specific.yml | 54 +++++++++++++++++++++++ README.md | 8 ++-- build.gradle | 1 + docs/migration.md | 2 +- 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100755 .github/scripts/update-version.sh create mode 100644 .github/workflows/repository-specific.yml diff --git a/.github/scripts/update-version.sh b/.github/scripts/update-version.sh new file mode 100755 index 0000000..77136c0 --- /dev/null +++ b/.github/scripts/update-version.sh @@ -0,0 +1,8 @@ +if [ ! -z $(git diff --name-only HEAD HEAD~1 | grep dependencies.gradle) ]; then + new_version="$(git log -n1 --format=format:"%H")" + sed --in-place "s!//version:.*!//version: $new_version!g" build.gradle + git add build.gradle + git commit -m "update buildscript version to $new_version" + git push + echo "[ci skip] update buildscript version"; +fi diff --git a/.github/workflows/repository-specific.yml b/.github/workflows/repository-specific.yml new file mode 100644 index 0000000..4768ea4 --- /dev/null +++ b/.github/workflows/repository-specific.yml @@ -0,0 +1,54 @@ +# This workflow only meant for the source mod youy shouldn't bring it into your own project + +name: Buildscript update CI + +on: + push: + branches: [ master, main, buildscript-versioning-and-migration-zip ] # todo: remove temporary test branch from here + pull_request: + branches: [ master, main ] + +jobs: + buildscript-maintenece: + runs-on: ubuntu-latest + steps: + - name: ensure build script version is updated + run: ./.github/scripts/update-version.sh + + zip-packages: + runs-on: ubuntu-latest + steps: + - name: Zip migration + run: > + zip -r migration.zip . \ + \ + -x "*.git/*" \ + \ + -x ".github/scripts/update-version.sh" \ + -x ".github/workflows/repository-specific.yml" \ + \ + -x "*docs/*" \ + -x "*src/*" \ + -x "LICENSE" \ + -x "README.md" + + - name: Zip starter + run: > + zip -r starter.zip . \ + \ + -x "*.git/*" \ + \ + -x ".github/scripts/update-version.sh" \ + -x ".github/workflows/repository-specific.yml" \ + \ + -x "*docs/*" \ + -x "LICENSE" \ + -x "README.md" + + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "latest-packages" + prerelease: true + title: "Latest starter and migration packages" + files: "*.zip" diff --git a/README.md b/README.md index 3bef3f5..b0ef929 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ We had our fair share in struggles with build scripts for Minecraft Forge. There ### Getting started Creating mod from scratch: -1. Fork this repository (you can keep the fork to simplify merging any build script updates in the future) -2. Clone repository +1. Unzip [project starter](TODO: insert the latest starter.zip link) +2. Commit it to your VCS of choice for later reference (e.g. in root directory `git init; git commit -m "initialise repository"`) 3. Replace placeholders (edit values in gradle.properties, change example package and class names, etc.) 4. Run `./gradlew setupDecompWorkspace` (if build fails with `Could not find :forgeBin:1.7.10-10.13.4.1614-1.7.10.` this should fix it) -5. Make sure to checkout the rest sections of this file. -6. You are good to go! +5. Make sure to check out the rest sections of this file. +6. You are good to go! We also have described guidelines for existing mod [migration](docs/migration.md) and [porting](docs/porting.md) diff --git a/build.gradle b/build.gradle index 46f5232..715ee07 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,4 @@ +//version: commit hash placeholder /* DO NOT CHANGE THIS FILE! diff --git a/docs/migration.md b/docs/migration.md index 4b92331..21bb17e 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -5,7 +5,7 @@ Migration for the typical mod which doesn't use anything special but Minecraft f For core plugin, Mixins, shadowing, access transformers, ASM or etc. you'll need to do some extra steps. If they are missing in this document - we will gladly receive your suggestions/contribution. -1. Copy and replace all files from template to your repository, but: +1. Copy and replace all files from [template](TODO: insert the latest migration.zip link) to your repository, but: 1. `build.gradle` 2. `src` 3. `LICENSE`