Skip to content

Update the version determination to allow lightweight tags as well #33

Update the version determination to allow lightweight tags as well

Update the version determination to allow lightweight tags as well #33

Workflow file for this run

name: Build and publish a release
on:
# NOTE: We specifically do *not* support `workflow_dispatch` here, because if we run this from
# workflow_dispatch, it will create a tag & release named /refs/heads/master or similar.
# This is a pain to deal with and we can always just delete the tag and tag a later commit
# if we need to make fixes as part of the release process.
push:
tags:
- '*'
jobs:
run-tests:
uses: ./.github/workflows/run_tests.yml
build-release:
name: Build Release
runs-on: windows-latest
needs: run-tests
steps:
- name: Add MSBuild to the PATH
uses: microsoft/setup-msbuild@v2
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all the history so that `git describe` works to generate the version header
fetch-tags: true
- name: Check that tag description matches the release version
continue-on-error: false # The C++ compilation uses `git describe HEAD` while the release creation uses the tag given by the Github Actions trigger, these should match
shell: bash
run: |
tag_description=$(git describe --tags --first-parent HEAD)
release_version="${GITHUB_REF#refs/tags/}"
echo "Checking tag description \"$tag_description\" against release version \"$release_version\"..."
if [ "$tag_description" == "$release_version" ]; then
echo "Release descriptions match, release can continue..."
else
echo "Release descriptions do NOT match, failing the release..."
exit 1
fi
- name: Build 32-bit binary
run: msbuild /r /m /p:Configuration=Release /p:Platform=x86 build\foo_openlyrics.sln
- name: Build 64-bit binary
run: msbuild /r /m /p:Configuration=Release /p:Platform=x64 build\foo_openlyrics.sln
- name: Pack binary into archive
shell: bash
run: |
release_version="${GITHUB_REF#refs/tags/}"
release_name="foo_openlyrics-${release_version}"
echo "Release version ${release_version}"
mkdir -p build_component_staging/x64
pushd build_component_staging
cp "../build/Release/foo_openlyrics.dll" "."
cp "../build/x64/Release/foo_openlyrics.dll" "x64/"
7z a -tzip "../${release_name}.fb2k-component" "."
popd
mkdir -p build_symbols_staging/x86
mkdir -p build_symbols_staging/x64
pushd build_symbols_staging
cp "../build/Release/foo_openlyrics.dll" "x86/"
cp "../build/Release/foo_openlyrics.pdb" "x86/"
cp "../build/x64/Release/foo_openlyrics.dll" "x64/"
cp "../build/x64/Release/foo_openlyrics.pdb" "x64/"
7z a "../${release_name}-with_debug_symbols.zip" "."
popd
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV
echo "RELEASE_NAME=${release_name}" >> $GITHUB_ENV
- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.RELEASE_NAME }}.fb2k-component
${{ env.RELEASE_NAME }}-with_debug_symbols.zip