Skip to content

Commit

Permalink
Create binary archives on tag creation (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncesario-lunarg committed Dec 20, 2023
1 parent c155f88 commit 2cac016
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = async ({github, context, core}) => {
const releaseTag = context.ref.replace('refs/tags/', '');

//try {
// await github.rest.git.updateRef({
// owner: context.repo.owner,
// repo: context.repo.repo,
// ref: releaseTag,
// sha: context.sha
// })
//} catch (error) {
// core.setFailed(`upload ${releaseTag} tag; ${error.name}; ${error.message}`)
//}

let release = null;
try {
release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: releaseTag
})
} catch (error) {
core.setFailed(`get the main release; ${error.name}; ${error.message}`)
}

try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id
})
} catch (error) {
core.setFailed(`update the main release; ${error.name}; ${error.message}`)
}

let release_assets = null;
try {
release_assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id
})
} catch (error) {
core.setFailed(`list release assets; ${error.name}; ${error.message}`)
}

const { ARCHIVE } = process.env
for (const release_asset of release_assets.data) {
if (release_asset.name === `${ ARCHIVE }`) {
try {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: release_asset.id
})
} catch (error) {
core.setFailed(`delete ${ ARCHIVE }; ${error.name}; ${error.message}`)
}
}
}

try {
const asset_path = `./build/install/${ ARCHIVE }`
const fs = require("fs")
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: `${ ARCHIVE }`,
data: fs.readFileSync(asset_path)
})
} catch (error) {
core.setFailed(`upload ${ ARCHIVE }; ${error.name}; ${error.message}`)
}
}

138 changes: 138 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# NOTE: The following documentation may be useful to maintainers of this workflow.
# Github actions: https://docs.github.com/en/actions
# Github github-script action: https://github.com/actions/github-script
# GitHub REST API: https://docs.github.com/en/rest
# Octokit front-end to the GitHub REST API: https://octokit.github.io/rest.js/v18
# Octokit endpoint methods: https://github.com/octokit/plugin-rest-endpoint-methods.js/tree/master/docs/repos

# TODO: Use actions/upload-artifact and actions/download-artifact to simplify deployment.
# TODO: Use composite actions to refactor redundant code.

name: Create Release Archives

on:
release:
types: [released]
paths-ignore:
- 'README.md'
- 'README-spirv-remap.txt'
- 'LICENSE.txt'
- 'CODE_OF_CONDUCT.md'
- 'BUILD.*'
- 'WORKSPACE'
- 'kokoro/*'
- 'make-revision'
- 'Android.mk'
- '_config.yml'

permissions: read-all

jobs:
unix:
runs-on: ${{matrix.os.genus}}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: [
{genus: ubuntu-22.04, family: linux, cc: gcc, cxx: g++, ccache: ccache},
{genus: macos-11, family: osx, cc: clang, cxx: clang++, ccache: ''}
]
cmake_build_type: [Debug, Release]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: lukka/get-cmake@2654d8ee382b9b6cbbfe6487653b8629b4e062c8 # v3.28.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.7'
- name: Setup ccache
uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10
with:
key: ${{ matrix.os.genus }}-${{ matrix.cmake_build_type }}-${{ matrix.os.cc }}-${{matrix.os.cxx}}
- run: python3 ./update_glslang_sources.py
- name: Configure
if: ${{ matrix.os.family }} != 'windows'
run: cmake -GNinja -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} -DBUILD_WERROR=ON -DCMAKE_C_COMPILER=${{ matrix.os.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.os.cxx }}
env:
CMAKE_C_COMPILER_LAUNCHER: ${{ matrix.os.ccache }}
CMAKE_CXX_COMPILER_LAUNCHER: ${{ matrix.os.ccache }}
- name: Build
run: cmake --build build
- name: Install
run: cmake --install build --prefix build/install
- name: Zip
env:
ARCHIVE: glslang-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
run: |
cd build/install
zip ${{env.ARCHIVE}} \
bin/glslang \
bin/glslangValidator \
include/glslang/* \
include/glslang/**/* \
lib/libGenericCodeGen.a \
lib/libglslang.a \
lib/libglslang-default-resource-limits.a \
lib/libMachineIndependent.a \
lib/libOSDependent.a \
lib/libSPIRV.a \
lib/libSPVRemapper.a \
lib/libSPIRV-Tools.a \
lib/libSPIRV-Tools-opt.a
- name: Upload Assets
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
build/install/glslang-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
windows:
runs-on: ${{matrix.os.genus}}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: [
{genus: windows-2019, family: windows}
]
cmake_build_type: [Debug, Release]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: lukka/get-cmake@2654d8ee382b9b6cbbfe6487653b8629b4e062c8 # v3.28.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.7'
- run: python3 ./update_glslang_sources.py
- name: Configure
run: cmake -Bbuild -G "Visual Studio 16 2019" -A x64 -B build -DBUILD_WERROR=ON
- name: Build
run: cmake --build build --config ${{ matrix.cmake_build_type }}
- name: Install
run: cmake --install build --prefix build/install --config ${{ matrix.cmake_build_type }}
- name: Zip
env:
ARCHIVE: glslang-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
run: |
cd build/install
zip ${{env.ARCHIVE}} `
bin/glslang.exe `
bin/glslangValidator.exe `
bin/spirv-remap.exe `
include/glslang/* `
lib/GenericCodeGen.lib `
lib/glslang.lib `
lib/glslang-default-resource-limits.lib `
lib/HLSL.lib `
lib/MachineIndependent.lib `
lib/OGLCompiler.lib `
lib/OSDependent.lib `
lib/SPIRV.lib `
lib/SPVRemapper.lib `
lib/SPIRV-Tools.lib `
lib/SPIRV-Tools-opt.lib
- name: Upload Assets
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
build/install/glslang-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip

0 comments on commit 2cac016

Please sign in to comment.