diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 5bbe28a989..5400b6cb75 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -70,3 +70,28 @@ jobs: with: name: premake-windows-${{ matrix.platform }} path: bin\${{ matrix.config }}\ + source: + runs-on: ubuntu-latest + strategy: + matrix: + config: [release] + platform: [x64] + needs: [linux, macosx, windows] # Pass all builds before creating source bundle + steps: + - name: Checkout # Need to checkout to get the package action + uses: actions/checkout@v3 + - name: Download Release + uses: actions/download-artifact@v3 + with: + name: premake-linux-${{ matrix.platform }} + - name: Generate Sources for Push + if: github.event_name != 'pull_request' + run: chmod 555 ./premake5 && ./premake5 package ${{ github.head_ref || github.ref_name }} source force + - name: Generate Sources for Pull Request + if: github.event_name == 'pull_request' + run: chmod 555 ./premake5 && ./premake5 package pull/${{ github.event.pull_request.number }}/head source force + - name: Upload Artifacts + uses: actions/upload-artifact@v2 + with: + name: premake-src + path: release/ diff --git a/scripts/package.lua b/scripts/package.lua index 25244ab2c4..9288a37e59 100644 --- a/scripts/package.lua +++ b/scripts/package.lua @@ -47,7 +47,7 @@ error("Unsupported host os", 0) end - local usage = 'usage is: package []\n' .. + local usage = 'usage is: package [] [force]\n' .. ' is the name of the release branch to target\n' .. ' is one of "source" or "binary"\n' .. ' (default: ' .. allowedCompilers[1] .. ') is one of ' .. table.implode(allowedCompilers, "", "", " ") @@ -60,6 +60,13 @@ local kind = _ARGS[2] local compiler = _ARGS[3] or allowedCompilers[1] + -- TODO: Figure out a better way to parse multiple optional args to this script + if compiler == 'force' and not table.contains(allowedCompilers, compiler) then + compiler = allowedCompilers[1] + end + + local forced = _ARGS[4] == 'force' or _ARGS[3] == 'force' or false + if kind ~= "source" and kind ~= "binary" then print("Invalid package kind: "..kind) error(usage, 0) @@ -96,7 +103,7 @@ -- os.chdir("..") - local text = os.outputof(string.format('git show %s:src/host/premake.h', branch)) + local text = os.outputof(string.format('git show HEAD:src/host/premake.h')) local _, _, version = text:find('VERSION%s*"([%w%p]+)"') local pkgName = "premake-" .. version @@ -121,7 +128,9 @@ printf(" ...from the %s branch", branch) printf("") printf("Does this look right to you? If so, press [Enter] to begin.") - io.read() + if not forced then + io.read() + end -- @@ -134,11 +143,21 @@ os.rmdir(pkgName) print("Cloning source code") - local z = execQuiet("git clone .. %s -b %s --recurse-submodules --depth 1 --shallow-submodules", pkgName, branch) + local z = execQuiet("git clone .. %s --recurse-submodules --depth 1 --shallow-submodules", pkgName) if not z then error("clone failed", 0) end + z = execQuiet("git fetch origin %s:pr", branch) + if not z then + error("fetch failed", 0) + end + + z = execQuiet("git checkout pr") + if not z then + error("checkout failed") + end + os.chdir(pkgName) --