As caches are immutable, try to append job id to it and figure out pr… #22
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: Build & Deploy HLSDK | |
on: [push, pull_request] | |
jobs: | |
get_prev_runid: | |
runs-on: ubuntu-latest | |
outputs: | |
value: ${{ steps.do.outputs.value }} | |
steps: | |
- id: do | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
value=$(gh run -R ${{ github.repository }} list --branch master -s completed -L 1 --json databaseId --jq '.[0].databaseId') | |
echo "Last run ID is $value" | |
echo "value=$value" >> "$GITHUB_OUTPUT" | |
build: | |
runs-on: ${{ matrix.os }} | |
needs: get_prev_runid | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: amd64 | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: i386 | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: arm64 | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: armhf | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: riscv64 | |
- os: ubuntu-20.04 | |
targetos: linux | |
targetarch: ppc64el | |
- os: windows-latest | |
targetos: win32 | |
targetarch: amd64 | |
- os: windows-2019 # always use the oldest possible for 32-bit because of older compilers, and better support of certain legacy OSes | |
targetos: win32 | |
targetarch: i386 | |
- os: macos-14 # arm64 as per github documentation | |
targetos: apple | |
targetarch: arm64 | |
- os: macos-13 # x86 as per github documentation (will they fix it before they deprecate this version?..) | |
targetos: apple | |
targetarch: amd64 | |
env: | |
YQ_VERSION: 4.44.6 | |
GH_CPU_OS: ${{ matrix.targetos }} | |
GH_CPU_ARCH: ${{ matrix.targetarch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install dependencies | |
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh | |
- name: Restore object files | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
hlsdk-portable/build | |
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ needs.get_prev_runid.outputs.value }} | |
- name: Build HLSDK | |
env: | |
FWGS_PFX_PASSWORD: ${{ secrets.FWGS_PFX_PASSWORD }} | |
run: bash scripts/gha/build_${{ matrix.targetos }}.sh | |
- name: Upload HLSDK (artifacts) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }} | |
path: out/* | |
- name: Save object files | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
hlsdk-portable/build | |
key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ github.job }} | |
release: | |
name: "Upload releases" | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Remove old release, fetch artifacts, repackage binaries and upload new release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }} | |
run: | | |
gh release delete "$RELEASE_TAG" \ | |
--yes \ | |
--cleanup-tag \ | |
--repo "$GITHUB_REPOSITORY" || true | |
sleep 20s | |
gh run download "$GITHUB_RUN_ID" \ | |
--dir out/ \ | |
--repo "$GITHUB_REPOSITORY" | |
pushd out/ | |
echo "Found artifacts:" | |
ls | |
for i in $(find -mindepth 1 -maxdepth 1 -type d); do | |
mv "$i"/* . | |
rm -rf "$i" | |
done | |
echo "Repackaged artifacts:" | |
ls -R | |
popd | |
sleep 20s | |
gh release create "$RELEASE_TAG" out/* \ | |
--title "HLSDK Mega Continuous ${{ github.ref_name }} Build" \ | |
--target $GITHUB_SHA \ | |
--repo "$GITHUB_REPOSITORY" \ | |
--prerelease |