Repository navigation
New Release Branch #23
Workflow file for this run
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
| # The MIT License (MIT) | |
| # | |
| # Copyright (c) 2025 - 2026 luau-project [https://github.com/luau-project/setup-lua](https://github.com/luau-project/setup-lua) | |
| # Copyright (c) 2026 - 2026 setup-lua contributors [https://github.com/luau-project/setup-lua](https://github.com/luau-project/setup-lua) | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all | |
| # copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| # SOFTWARE. | |
| name: New Release Branch | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| kind: | |
| description: The kind of a new release | |
| type: choice | |
| required: true | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| jobs: | |
| version-info: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| new-version: ${{ steps.version.outputs.new-version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Extract version from package.json | |
| id: version | |
| shell: pwsh | |
| run: | | |
| if (-not (Test-Path "package.json")) { | |
| Write-Host "package.json not found"; | |
| exit 1; | |
| } | |
| $version = & jq -j '.version' "package.json"; | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "Unable to find the package version"; | |
| exit 1; | |
| } | |
| if (-not ($version -match "^(\d+)\.(\d+)\.(\d+)$")) { | |
| Write-Host "Invalid version format"; | |
| exit 1; | |
| } | |
| $major = [int]::Parse($Matches[1]); | |
| $minor = [int]::Parse($Matches[2]); | |
| $patch = [int]::Parse($Matches[3]); | |
| if ("${{ inputs.kind }}" -eq "major") { | |
| $major++; | |
| $minor = 0; | |
| $patch = 0; | |
| } | |
| elseif ("${{ inputs.kind }}" -eq "minor") { | |
| $minor++; | |
| $patch = 0; | |
| } | |
| elseif ("${{ inputs.kind }}" -eq "patch") { | |
| $patch++; | |
| } | |
| else { | |
| Write-Host "Unknown kind of tag"; | |
| exit 1; | |
| } | |
| Add-Content "$env:GITHUB_OUTPUT" "version=${version}"; | |
| Add-Content "$env:GITHUB_OUTPUT" "new-version=${major}.${minor}.${patch}"; | |
| new-version-changes: | |
| runs-on: ubuntu-latest | |
| needs: version-info | |
| if: ${{ github.actor == 'luau-project' && github.triggering_actor == 'luau-project' && github.repository == 'luau-project/setup-lua' }} | |
| env: | |
| NEW_BRANCH: release-${{ needs.version-info.outputs.new-version }} | |
| RELEASE_COMMIT_MSG: 'Release v${{ needs.version-info.outputs.new-version }}' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.ref }} | |
| token: ${{ secrets.SETUP_LUA_UPDATE_DIST_TOKEN }} | |
| - name: Create a new branch | |
| run: git checkout -b ${{ env.NEW_BRANCH }} | |
| - name: Change version on package.json | |
| run: | | |
| sed -e "s/\"version\": \"${{ needs.version-info.outputs.version }}\"/\"version\": \"${{ needs.version-info.outputs.new-version }}\"/g" -i package.json | |
| - name: Change version on docs | |
| if: ${{ inputs.kind == 'major' }} | |
| run: | | |
| old_major=$(echo "${{ needs.version-info.outputs.version }}" | cut -d. -f1) | |
| new_major=$(echo "${{ needs.version-info.outputs.new-version }}" | cut -d. -f1) | |
| sed \ | |
| -e "s/setup\-lua\@v${old_major}/setup-lua@v${new_major}/g" \ | |
| -e "s/setup\-lua\-${old_major}/setup-lua-${new_major}/g" \ | |
| -e "s/v${old_major}\\.tar\\.gz/v${new_major}\\.tar\\.gz/g" \ | |
| -i README.md | |
| sed \ | |
| -e "s/setup\-lua\@v${old_major}/setup-lua@v${new_major}/g" \ | |
| -e "s/setup\-lua\-${old_major}/setup-lua-${new_major}/g" \ | |
| -e "s/v${old_major}\\.tar\\.gz/v${new_major}\\.tar\\.gz/g" \ | |
| -i docs/GitHub.md | |
| - name: Setup node 24 | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: 24 | |
| - name: Install packages | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| - name: Set user name and email on commit | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Stage changes | |
| run: git add . | |
| - name: Commit changes | |
| run: git commit "--message=${{ env.RELEASE_COMMIT_MSG }}" | |
| - name: Print diff | |
| run: git show | |
| - name: Push changes | |
| run: git push --set-upstream origin ${{ env.NEW_BRANCH }} |