Skip to content

ci: refactor build to allow continuation on error #45

ci: refactor build to allow continuation on error

ci: refactor build to allow continuation on error #45

Workflow file for this run

# Copyright (c) 2020-2021-2022 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT
#
# The peculiarity of this workflow is that assumes vcpkg is NOT stored as a submodule of this repository.
# This workflow does the following:
# - Restores vcpkg artifacts from cache.
# - Using the provided Git commit id, sets up vcpkg if needed, then run CMake with CMakePreset.json using a configuration
# that leverages the vcpkg's toolchain file. This will automatically run vcpkg to install dependencies
# described by the vcpkg.json manifest file. It will be a no-op if those are restored from cache.
# - Finally builds the sources with Ninja.
name: Semantic Release
on:
push:
workflow_dispatch:
inputs:
trigger_nexus_upload:
description: "Trigger Nexus upload"
required: false
default: "false"
env:
FILENAME: CrashLogger # Define the filename here to use globally
jobs:
semantic_release:
name: Semantic Release
runs-on: windows-latest
if: github.repository_owner == 'alandtse'
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- uses: lukka/get-cmake@latest
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
@semantic-release/github
@google/semantic-release-replace-plugin
dry_run: false
semantic_version: 24.1.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set output release ouutput
run: echo "new_release=${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_ENV
build_cmake:
name: Build with CMake
runs-on: windows-latest
if: github.repository_owner == 'alandtse'
needs: semantic_release
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Check if GitHub release tag exists
id: check_release
run: |
RELEASE_VERSION=$(git describe --tags --abbrev=0)
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_ENV
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://github.com/gitapi/repos/${{ github.repository }}/releases/tags/${RELEASE_VERSION} \
| jq -r '.assets[]?.name' > assets.txt
if grep -q "${{ env.FILENAME }}_${RELEASE_VERSION}.7z" assets.txt; then
echo "asset_exists=true" >> $GITHUB_ENV
else
echo "asset_exists=false" >> $GITHUB_ENV
- name: Extract vcpkgGitCommitId from vcpkg.json
id: extract_commit_id
run: |
vcpkg_commit_id=$(cat vcpkg.json | jq -r '.["builtin-baseline"]')
echo "vcpkg_commit_id=$vcpkg_commit_id" >> $GITHUB_ENV
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v10
id: runvcpkg
with:
vcpkgDirectory: "${{ runner.workspace }}/b/vcpkg"
vcpkgGitCommitId: ${{ env.vcpkg_commit_id }}
vcpkgJsonGlob: "/vcpkg.json"
- name: Prints output of run-vcpkg's action
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}'"
- uses: lukka/run-cmake@v10
if: ${{ env.asset_exists == 'false' || env.new_release == 'true' }}
with:
cmakeListsTxtPath: "${{ github.workspace }}/CMakeLists.txt"
configurePreset: Release-MSVC
buildPreset: Release-MSVC
upload_github_release:
name: Upload to GitHub Release
runs-on: windows-latest
needs: build_cmake
if: ${{ env.asset_exists == 'false' || env.new_release == 'true' }}

Check failure on line 106 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / Semantic Release

Invalid workflow file

The workflow is not valid. .github/workflows/build.yml (Line: 106, Col: 9): Unrecognized named-value: 'env'. Located at position 1 within expression: env.asset_exists == 'false' || env.new_release == 'true'
steps:
- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@2.3.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: build/release-msvc/${{ env.FILENAME }}_${{ env.release_version }}.7z
tag: ${{ env.release_version }}
overwrite: true
upload_nexus:
name: Upload to Nexus
runs-on: windows-latest
needs: upload_github_release
if: github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_nexus_upload == 'true' || env.new_release == 'true' && github.repository_owner == 'alandtse'
steps:
- name: Check if file exists in Nexus
id: check_nexus_release
run: |
# Insert Nexus API check logic here
echo "nexus_file_exists=false" >> $GITHUB_ENV
- name: Setup Dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: Download NexusUploader
run: dotnet tool install -g BUTR.NexusUploader
- name: Get changelog from GitHub release
id: fetch_release
run: |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://github.com/gitapi/repos/${{ github.repository }}/releases/tags/${{ env.release_version }} \
| jq -r '.id')
CHANGELOG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://github.com/gitapi/repos/${{ github.repository }}/releases/$RELEASE_ID \
| jq -r '.body')
echo "changelog=$CHANGELOG" >> $GITHUB_ENV
- name: Upload files to Nexus
# https://github.com/agc93/nexus-uploader using fork https://github.com/BUTR/BUTR.NexusUploader
env:
UNEX_SESSION_COOKIE: ${{ secrets.NEXUSMODS_SESSION_COOKIE }}
UNEX_APIKEY: ${{ secrets.UNEX_APIKEY }}
UNEX_GAME: skyrimspecialedition
UNEX_MODID: 59818
UNEX_FILENAME: ${{ env.FILENAME }}
UNEX_FILEDESCRIPTION: |-
See Description -> Requirements for installation instructions.
PDB is for crash debugging and can be removed.
UNEX_PREVIOUSFILE: "auto"
file: build/release-msvc/${{ env.UNEX_FILENAME }}_${{ env.release_version }}.7z
version: ${{ env.release_version }}
changelog: ${{ env.changelog }}
run: |
unex upload $UNEX_MODID $file -v $version
unex changelog $version -c "$changelog"