Skip to content

Commit

Permalink
Added force path for packaging, updated CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nickclark2016 committed Jun 12, 2022
1 parent b2016d4 commit 3e2382f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
27 changes: 23 additions & 4 deletions scripts/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
error("Unsupported host os", 0)
end

local usage = 'usage is: package <branch> <type> [<compiler>]\n' ..
local usage = 'usage is: package <branch> <type> [<compiler>] [force]\n' ..
' <branch> is the name of the release branch to target\n' ..
' <type> is one of "source" or "binary"\n' ..
' <compiler> (default: ' .. allowedCompilers[1] .. ') is one of ' .. table.implode(allowedCompilers, "", "", " ")
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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


--
Expand All @@ -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)

--
Expand Down

0 comments on commit 3e2382f

Please sign in to comment.