Merge pull request #63 from xesdoog/main #56
This file contains hidden or 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
| name: Zip Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**.lua' | |
| tags: | |
| - '*' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ss_ci-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| main: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@master | |
| with: | |
| fetch-depth: 0 | |
| - 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: owner, | |
| repo: repo, | |
| } | |
| ); | |
| let new_tag; | |
| let old_tag; | |
| if (tags.data.length === 0) { | |
| console.log('No existing tags found. Starting with version 1.0.0'); | |
| new_tag = 'v1.0.0'; | |
| } | |
| else { | |
| const latest_tag = tags.data[0].name; | |
| const tag_part = latest_tag.substring(1).split('.').map(Number); | |
| if (tag_part[1] === 9 && tag_part[2] === 9) { | |
| tag_part[0] += 1; | |
| tag_part[1] = 0; | |
| tag_part[2] = 0; | |
| } | |
| else if (tag_part[2] === 9) { | |
| tag_part[1] += 1; | |
| tag_part[2] = 0; | |
| } | |
| else { | |
| tag_part[2] += 1; | |
| } | |
| new_tag = `v${tag_part.join('.')}`; | |
| old_tag = latest_tag; | |
| } | |
| core.setOutput("version_number", new_tag); | |
| core.setOutput("old_tag", old_tag); | |
| - name: Write Changelog | |
| id: write_changelog | |
| run: | | |
| commitMessage=$(git log -1 --pretty=format:"%s") | |
| commitBody=$(git log -1 --pretty=format:"%b") | |
| echo "Commit Message: $commitMessage" | |
| echo "Commit Body: $commitBody" | |
| { | |
| echo "changelog_body<<EOF" | |
| echo "$commitMessage" | |
| echo "" | |
| echo "$commitBody" | |
| echo "EOF" | |
| } >> "$GITHUB_ENV" | |
| shell: bash | |
| - 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* *.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 | |
| - name: Update README.md | |
| run: | | |
| 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 README.md | |
| git diff --cached --quiet || git commit -m "Update README version badge to ${{steps.increment_tag.outputs.version_number}}" | |
| git push |