71 lines
2.3 KiB
YAML
71 lines
2.3 KiB
YAML
name: Version Bumper and Tagger
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
check-version-change:
|
|
if: github.repository_owner == 'Steamopollys'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version_changed: ${{ steps.detect-version-change.outputs.version_changed }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2 # Fetch the current and previous commit for comparison
|
|
|
|
- name: Detect version change
|
|
id: detect-version-change
|
|
run: |
|
|
echo ::set-output name=version_changed::$(git diff HEAD^ HEAD -- manifest.json | grep -q '"version_number":' && echo "true" || echo "false")
|
|
|
|
bump-and-tag-version:
|
|
needs: check-version-change
|
|
if: needs.check-version-change.outputs.version_changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0 # Necessary for tagging to include all history
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.9'
|
|
|
|
- name: Bump version and create tag
|
|
run: |
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
# Load and parse manifest.json
|
|
manifest_path = Path('manifest.json')
|
|
manifest = json.loads(manifest_path.read_text())
|
|
version_number = manifest['version_number']
|
|
|
|
# Update core/core.lua
|
|
core_lua_path = Path('core/core.lua')
|
|
core_lua_content = core_lua_path.read_text()
|
|
core_lua_content = re.sub(r'MODDED_VERSION = "\d+\.\d+\.\d+-STEAMODDED"', f'MODDED_VERSION = "{version_number}-STEAMODDED"', core_lua_content)
|
|
core_lua_path.write_text(core_lua_content)
|
|
|
|
# Output version number for later steps
|
|
print(f"::set-output name=version_number::{version_number}")
|
|
id: bump-version
|
|
shell: python
|
|
|
|
- name: Commit and push if changed
|
|
uses: stefanzweifel/git-auto-commit-action@v4
|
|
with:
|
|
commit_message: "Automatically bump version to ${{ needs.bump-and-tag-version.outputs.version_number }}"
|
|
file_pattern: core/core.lua injector.ps1
|
|
|
|
- name: Create and push tag
|
|
if: steps.bump-version.outputs.version_number
|
|
env:
|
|
VERSION: ${{ steps.bump-version.outputs.version_number }}
|
|
run: |
|
|
git tag $VERSION
|
|
git push origin $VERSION
|
|
|