Skip to content

Commit 7ea1557

Browse files
committed
Initial Commit
1 parent 92a2d2d commit 7ea1557

File tree

11 files changed

+297
-0
lines changed

11 files changed

+297
-0
lines changed

.github/workflows/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
if: github.repository == 'PolyhedralDev/DefaultMetapack' && github.event_name == 'push'
15+
16+
env:
17+
repo_url: ${{ github.server_url }}/${{ github.repository }}
18+
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: '2'
24+
25+
- name: Check for version bump
26+
run: bash ./.scripts/check-version-bump.sh
27+
28+
- name: Create artifacts
29+
run: bash ./.scripts/pack.sh
30+
31+
- name: Grab release changelog
32+
if: env.version-bumped == 'true'
33+
run: bash ./.scripts/changelog/extract-release-changelog.sh
34+
35+
- name: Update changelog
36+
if: env.version-bumped == 'true'
37+
run: bash ./.scripts/changelog/update-changelog.sh
38+
39+
- name: Push changelog
40+
if: env.version-bumped == 'true'
41+
uses: EndBug/add-and-commit@v9
42+
with:
43+
author_name: Polyhedral-Bot
44+
author_email: [email protected]
45+
message: Version ${{ env.version }}
46+
tag: v${{ env.version }} -F ${{ env.release_changelog }} --cleanup=verbatim
47+
add: CHANGELOG.md
48+
49+
- name: Release
50+
if: env.version-bumped == 'true'
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
tag_name: v${{ env.version }}
54+
body_path: ${{ env.release_changelog }}
55+
files: |
56+
.artifacts/*
57+
58+
- name: Release latest
59+
uses: "marvinpinto/action-automatic-releases@latest"
60+
with:
61+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
62+
automatic_release_tag: "latest"
63+
prerelease: false
64+
title: "Latest Build"
65+
files: |
66+
.artifacts/*

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
*.iml
3+
*.ipr
4+
*.jar
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Grabs the unreleased section from the changelog, and cleans it up for publication
4+
5+
source ./.scripts/lib.sh
6+
source ./.scripts/vars.sh
7+
ensure_file "$CHANGELOG"
8+
9+
# Copy unreleased changelog to temporary file
10+
echo '- Extracting unreleased changelog'
11+
sed "0,/$UNRELEASED_SECTION_START_REGEX/ d; /$UNRELEASED_SECTION_END_REGEX/,$ d" $CHANGELOG > $RELEASE_CHANGELOG
12+
13+
# Remove unused subheadings from new changelog
14+
echo '- Stripping empty titles from changelog'
15+
echo "$(awk '/^$/ {if (i) {b=b $0 "\n"} else {print $0 }; next} \
16+
/^###/ {i=1; b=$0; next} {if (i) {print b}; i=0; print $0; next}' $RELEASE_CHANGELOG)" > $RELEASE_CHANGELOG
17+
18+
if ! grep -q '[^[:space:]]' "$RELEASE_CHANGELOG"; then
19+
echo '- WARNING: Unreleased changelog is empty!'
20+
fi
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Moves unreleased section to a new version release section, and updates anchors at the bottom of the changelog
4+
5+
source ./.scripts/lib.sh
6+
source ./.scripts/vars.sh
7+
ensure_env "version"
8+
ensure_env "previous_version"
9+
ensure_env "repo_url"
10+
ensure_file "$CHANGELOG"
11+
ensure_file "$RELEASE_CHANGELOG"
12+
13+
echo "Updating $CHANGELOG for v$version:"
14+
15+
echo '- Clearing unreleased section'
16+
replace_in_file "$CHANGELOG" "$UNRELEASED_SECTION_START_REGEX" "$UNRELEASED_SECTION_END_REGEX" "\
17+
### Added
18+
19+
20+
### Changed
21+
22+
23+
### Removed
24+
25+
26+
### Fixed
27+
28+
"
29+
30+
echo "- Inserting new version section"
31+
append_after "$CHANGELOG" "$VERSIONS_SECTION_START_REGEX" "
32+
33+
## [v$version]
34+
$(cat $RELEASE_CHANGELOG)"
35+
36+
echo '- Adding new version anchor'
37+
sed -i "/^\[Unreleased]/a [v$version]: $repo_url/compare/v$previous_version...v$version" $CHANGELOG
38+
39+
echo '- Updating unreleased anchor'
40+
sed -i "s|^\[Unreleased\]: .*|[Unreleased]: $repo_url/compare/v$version...HEAD|" $CHANGELOG
41+
42+
echo "v$version changelog:"
43+
echo '---'
44+
cat $RELEASE_CHANGELOG
45+
echo '---'

.scripts/check-version-bump.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
source ./.scripts/vars.sh
4+
5+
# Search HEAD diff for a change in the pack version
6+
version_diff=$(git diff HEAD^ HEAD "$PACK_MANIFEST" | grep '^+version: ')
7+
previous_version_diff=$(git diff HEAD^ HEAD "$PACK_MANIFEST" | grep '^-version: ')
8+
9+
# Strip version key to get version strings
10+
version=${version_diff#+version: }
11+
previous_version=${previous_version_diff#-version: }
12+
13+
# Export information to the workflow job environment
14+
if [ -z "$version" ]; then
15+
echo "No version change detected"
16+
echo "version-bumped=false" >> "$GITHUB_ENV"
17+
else
18+
echo "Detected version change v$previous_version -> v$version"
19+
echo "version-bumped=true" >> "$GITHUB_ENV"
20+
echo "previous_version=$previous_version" >> "$GITHUB_ENV"
21+
echo "version=$version" >> "$GITHUB_ENV"
22+
fi

.scripts/lib.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ensure_env() {
2+
local var_name="$1"
3+
if [ -z "${!var_name}" ]; then
4+
echo "Environment variable '$var_name' is not defined, aborting..."
5+
exit 1
6+
fi
7+
}
8+
9+
ensure_file() {
10+
if [ ! -f "$1" ]; then
11+
echo "No file found $1"
12+
exit 1
13+
fi
14+
}
15+
16+
delete_between() {
17+
local file="$1"
18+
local start_regex="$2"
19+
local end_regex="$3"
20+
sed -i "/$start_regex/,/$end_regex/{//!d}" "$file"
21+
}
22+
23+
append_after() {
24+
local file="$1"
25+
local regex="$2"
26+
local text="${3//$'\n'/\\$'\n'}" # Escape newlines in text
27+
sed -i "/$regex/a $text" "$file"
28+
}
29+
30+
replace_in_file() {
31+
local file="$1"
32+
local start_regex="$2"
33+
local end_regex="$3"
34+
local text="$4"
35+
delete_between "$file" "$start_regex" "$end_regex"
36+
append_after "$file" "$start_regex" "$text"
37+
}

.scripts/pack.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Sets up the files to be included in the release
4+
5+
mkdir .artifacts
6+
zip -r ./.artifacts/default.zip *

.scripts/upload-to-wiki.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Force pushes the comments of WIKI_DIRECTORY to the wiki page of WIKI_PARENT_REPOSITORY
4+
5+
if [ "$GITHUB_ACTIONS" != true ]; then
6+
echo "This script must be ran via GitHub actions."
7+
exit 1
8+
fi
9+
10+
echo "Deleting .git folder..."
11+
rm -rf .git
12+
13+
echo "Setting up temporary repository in $WIKI_DIRECTORY..."
14+
cd $WIKI_DIRECTORY
15+
git init
16+
17+
echo "Setting up authentication..."
18+
git config user.name $LOGIN_NAME
19+
git config user.email $LOGIN_EMAIL
20+
21+
echo "Committing changes..."
22+
git add *
23+
git commit -m "GitHub Action Deployment"
24+
25+
echo "Pushing to wiki..."
26+
git remote add origin https://$ACCESS_TOKEN@github.com/$WIKI_PARENT_REPOSITORY.wiki.git
27+
git push origin master --force

.scripts/vars.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CHANGELOG="CHANGELOG.md"
2+
RELEASE_CHANGELOG="RELEASE_CHANGELOG.md"
3+
PACK_MANIFEST="pack.yml"
4+
UNRELEASED_SECTION_START_REGEX="^## \\[Unreleased\\]"
5+
UNRELEASED_SECTION_END_REGEX="^<!--"
6+
VERSIONS_SECTION_START_REGEX="^-->"

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6+
7+
## Versioning
8+
9+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10+
11+
### Before You Update
12+
13+
Modifications made to Terra config packs may introduce changes in world generation.
14+
Updating an installed config pack is regarded as a modification, and may produce
15+
chunk borders between existing chunks and new chunks generated after updating a pack.
16+
17+
In this pack, version numbers are increased according to the degree of generation
18+
changes from the previous version as follows:
19+
20+
#### MAJOR Version (X.-.-)
21+
22+
*Changes that significantly modify generation such that chunk borders in all areas
23+
are guaranteed between versions.*
24+
25+
Examples of this include a complete rewrite of the pack, and or significant
26+
modifications to biome distribution.
27+
28+
#### MINOR Version (-.X.-)
29+
30+
*Changes that modify generation such that localized areas produce chunk borders.*
31+
32+
For example, any modification in biome distribution warrants an increase in the
33+
MINOR version. This includes things like biome additions, as a new biome may
34+
generate in an area where it previously did not (resulting in a chunk border).
35+
36+
#### PATCH Version (-.-.X)
37+
38+
*Changes that produce no significant chunk borders.*
39+
40+
---
41+
42+
## [Unreleased]
43+
44+
### Added
45+
46+
### Changed
47+
48+
### Removed
49+
50+
### Fixed
51+
52+
<!--
53+
DO NOT MODIFY TEXT BELOW, CI automatically manages new version sections for each
54+
new release. Add any new change logs to the [Unreleased] section above instead.
55+
-->
56+

0 commit comments

Comments
 (0)