Skip to content

Zip Release

Zip Release #6

Workflow file for this run

name: CI
on:
push:
branches:
- main
paths:
- "**/*.lua"
- "scripts/translations/**"
workflow_dispatch:
concurrency:
group: ss_ci-${{ github.ref }}
cancel-in-progress: true
jobs:
orchestrator:
name: CI Main
runs-on: ubuntu-latest
if: "! contains(github.event.head_commit.message, '[noci]')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Translations
id: check_translations
run: |
if git diff --name-only HEAD^ HEAD | grep -E 'scripts/translations/|hashmap.json|includes/lib/translations/__locales.lua|includes/lib/translations/en-US.lua'; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Setup Python
if: steps.check_translations.outputs.changed == 'true'
uses: actions/setup-python@v5
with:
python-version: "3.12.x"
- name: Generate Translations
if: steps.check_translations.outputs.changed == 'true'
run: |
cd ./scripts/translations
python generate_translations.py
- name: Add Translations
id: commit_translations
if: steps.check_translations.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add includes/lib/translations/
git add scripts/translations/hashmap.json || true
- name: Increment Tag
id: increment_tag
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const tags = await github.rest.repos.listTags({ owner, repo });
let no_prefix;
let new_tag;
let old_tag;
if (tags.data.length === 0) {
new_tag = 'v1.0.0';
no_prefix = '1.0.0';
} else {
const latest = tags.data[0].name.substring(1).split('.').map(Number);
if (latest[1] === 9 && latest[2] === 9) {
latest[0] += 1; latest[1] = 0; latest[2] = 0;
} else if (latest[2] === 9) {
latest[1] += 1; latest[2] = 0;
} else {
latest[2] += 1;
}
no_prefix = latest.join('.');
new_tag = `v${latest.join('.')}`;
old_tag = tags.data[0].name;
}
core.setOutput("version_number", new_tag);
core.setOutput("no_prefix", no_prefix);
core.setOutput("old_tag", old_tag);
- name: Bump Version
run: |
sed -i "s|return \".*\"|return \"${{steps.increment_tag.outputs.no_prefix}}\"|" includes/version.lua
sed -i "s|https://img.shields.io/badge/Script%20Version-v[0-9]\+\.[0-9]\+\.[0-9]\+-blue|https://img.shields.io/badge/Script%20Version-${{steps.increment_tag.outputs.version_number}}-blue|g" README.md
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add includes/version.lua README.md
git diff --cached --quiet || git commit -m "[noci] bump version"
git push
- name: Create Archive
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: "Samurais_Scripts_${{steps.increment_tag.outputs.version_number}}.zip"
exclusions: /.git* /scripts* /docs* *.json *.md *.editorconfig *.py
- name: Upload Release
uses: softprops/action-gh-release@v2
with:
name: Samurai's Scripts ${{steps.increment_tag.outputs.version_number}}
tag_name: ${{steps.increment_tag.outputs.version_number}}
body: |
### ${{steps.increment_tag.outputs.version_number}} Changelog
${{ env.changelog_body }}
files: |
Samurais_Scripts_${{steps.increment_tag.outputs.version_number}}.zip