-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instance) : add auto start to minecraft instance
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import sys | ||
import re | ||
import os | ||
from typing import Tuple | ||
|
||
|
||
def parse_changelog(changelog_path: str = 'CHANGELOG.md', with_v: bool = False) -> Tuple[str, str, str]: | ||
with open(changelog_path) as f: | ||
changelog = f.read() | ||
|
||
# Get the first (Highest Latest) version | ||
version_pattern = r'## \[(v?\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})' | ||
match = re.search(version_pattern, changelog) | ||
if not match: | ||
print('Version not found in CHANGELOG.md', file=sys.stderr) | ||
sys.exit(1) | ||
|
||
version, date = match.groups() | ||
version = version.strip() | ||
date = date.strip() | ||
|
||
# Extract Latest version details | ||
latest_version_pattern = r'## \[v?{0}\] - {1}(.*?)(?:\n## \[v?\d+\.\d+\.\d+\] - \d{{4}}-\d{{2}}-\d{{2}}|\Z)'.format( | ||
re.escape(version), re.escape(date)) | ||
match = re.search(latest_version_pattern, changelog, re.DOTALL) | ||
if not match: | ||
print('Latest version details not found in CHANGELOG.md', file=sys.stderr) | ||
sys.exit(1) | ||
|
||
latest_version_details = match.group(1).strip() | ||
|
||
return version, date, latest_version_details | ||
|
||
|
||
if __name__ == '__main__': | ||
# Parse sys.argv if specified | ||
version, date, latest_version_details = parse_changelog(*sys.argv[1:]) | ||
|
||
os.makedirs('github_action_outputs', exist_ok=True) | ||
|
||
# Write to file | ||
with open('./github_action_outputs/version.txt', 'w') as f: | ||
f.write(version) | ||
|
||
with open('./github_action_outputs/date.txt', 'w') as f: | ||
f.write(date) | ||
|
||
with open('./github_action_outputs/latest_version_details.txt', 'w') as f: | ||
f.write(latest_version_details) | ||
|
||
print(f'Version: {version}\nDate: {date}\nLatest Version Details:\n{latest_version_details}') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Release from Changelog | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'CHANGELOG.md' | ||
|
||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Parse Changelog | ||
run: | | ||
python .github/scripts/parse_changelog.py | ||
- name: Read Changelog Outputs | ||
id: read_changelog | ||
run: | | ||
version=$(cat github_action_outputs/version.txt) | ||
date=$(cat github_action_outputs/date.txt) | ||
details=$(cat github_action_outputs/latest_version_details.txt) | ||
echo "VERSION=$version" >> $GITHUB_ENV | ||
echo "DATE=$date" >> $GITHUB_ENV | ||
echo "DETAILS<<EOF" >> $GITHUB_ENV | ||
echo "$details" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Create Tag | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const version = process.env.VERSION; | ||
const tagName = `${version}`; | ||
const { data: tag } = await github.rest.git.createTag({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag: tagName, | ||
message: `Release ${tagName}`, | ||
object: context.sha, | ||
type: 'commit', | ||
}); | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${tagName}`, | ||
sha: tag.sha, | ||
}); | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
name: ${{ env.VERSION }} | ||
tag_name: ${{ env.VERSION }} | ||
body: ${{ env.DETAILS }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## [2.0.1] - 2024-11-15 | ||
### Added | ||
- Auto start minecraft server on container start suggested by [issue #12](https://github.com/WasinUddy/Montainer/issues/12) by [niker](https://github.com/niker) |
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