Skip to content

LuxCore Samples Releaser #4

LuxCore Samples Releaser

LuxCore Samples Releaser #4

# SPDX-FileCopyrightText: 2024 Howetuft
#
#
# SPDX-License-Identifier: Apache-2.0
name: LuxCore Samples Releaser
on:
workflow_dispatch:
inputs:
release-version:
description: "Release version (major.minor.patch[-pre])"
required: False
default: ''
type: string
allow-updates:
description: "Update existing release (if any)"
required: True
type: boolean
default: True
rebuild-all:
description: "Rebuild all"
required: True
type: boolean
default: False
jobs:
check-version:
name: 'Check version compliance'
runs-on: ubuntu-latest
steps:
- name: Check version compliance
if: ${{ inputs.release-version != '' }}
shell: python
run: |
import sys
import re
version = "${{ inputs.release-version }}"
semver_regex = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
res = re.fullmatch(semver_regex, version)
if res:
print(f"::notice::Version number OK ('{version}')")
else:
message = [
f"::error::INVALID RELEASE VERSION NUMBER '{version}'",
"Version must comply to Semantic Versioning standard:",
"\n\tmajor.minor.patch[-pre]\n",
"See https://semver.org for more information",
"or leave the field blank for default value\n"
]
print("\n".join(message))
sys.exit(1)
call-build-samples:
name: 'Build samples'
needs: [check-version]
uses: ./.github/workflows/sample-builder.yml
with:
repository: LuxCoreRender/LuxCore
version: ${{ inputs.release-version }}
create-release:
name: 'Create release'
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [call-build-samples]
permissions:
id-token: write
attestations: write
contents: write
steps:
- run: |
_version=${{ needs.call-build-samples.outputs.version }}
echo "Creating release '${_version}'"
echo "RELEASE_TAG=v${_version}" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: LuxCore-Samples-*
path: ${{ github.workspace }}/dist
merge-multiple: false
- name: Display structure of downloaded files
run: ls -Rl ${{ github.workspace }}/dist
- name: Re-zip artifacts
working-directory: ${{ github.workspace }}/dist
run: |
mkdir ../artifacts
for d in */ ; do
d2=${d%/}
echo "zip ${d2}"
zip -j ../artifacts/${d2}.zip ${d2}/*
done
- id: make-release
# Use full length commit SHA, otherwise CodeQL complains...
uses: ncipollo/release-action@cdcc88a9acf3ca41c16c37bb7d21b9ad48560d87
with:
name: "LuxCore Samples ${{ env.RELEASE_TAG }}"
tag: samples-${{ env.RELEASE_TAG }}
artifacts: artifacts/*
removeArtifacts: true
allowUpdates: ${{ inputs.allow-updates }}
prerelease: ${{ inputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
updateOnlyUnreleased: true
draft: true
body: |
## LuxCore Python Samples
This release was built from the following point in LuxCoreRender/LuxCore:
- Branch: ${{ needs.call-build-samples.outputs.branch }}
- Commit: ${{ needs.call-build-samples.outputs.commit }}
Attestations:
${{ needs.call-build-samples.outputs.attestation-url }}
- run: |
echo "### Release""" >> $GITHUB_STEP_SUMMARY
echo ${{ steps.make-release.outputs.html_url }} >> $GITHUB_STEP_SUMMARY