remiceres triggered GitHub release on v5.0.0 #1
Workflow file for this run
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: Publish GitHub Release | |
| run-name: ${{ github.actor }} triggered GitHub release on ${{ github.event.inputs.ref || github.ref_name }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "Tag to release (example: v5.0.0)" | |
| required: true | |
| type: string | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| concurrency: | |
| group: release-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-artifacts: | |
| uses: ./.github/workflows/_build-platform-artifacts.yml | |
| with: | |
| source_ref: ${{ github.event.inputs.ref || github.ref }} | |
| artifact_name_prefix: corese-gui | |
| project_version: ${{ github.event.inputs.ref || github.ref }} | |
| release: | |
| needs: build-artifacts | |
| runs-on: ubuntu-24.04 | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.ref || github.ref_name }} | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: corese-gui-* | |
| merge-multiple: true | |
| path: build/release-assets | |
| - name: Fail if SNAPSHOT assets are present | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd build/release-assets | |
| snapshot_files="$(find . -maxdepth 1 -type f -name '*-SNAPSHOT-*' -printf '%f\n' | sort || true)" | |
| if [[ -n "$snapshot_files" ]]; then | |
| echo "Release artifacts must not contain '-SNAPSHOT-' in filenames." >&2 | |
| echo "Set a stable version (for example: 5.0.0) before publishing." >&2 | |
| echo "" >&2 | |
| echo "Detected files:" >&2 | |
| echo "$snapshot_files" >&2 | |
| exit 1 | |
| fi | |
| - name: Add Flathub flatpakref asset | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| flatpakref_path="build/release-assets/fr.inria.corese.CoreseGui.flatpakref" | |
| cp packaging/flatpak/fr.inria.corese.CoreseGui.flatpakref "$flatpakref_path" | |
| # Best effort: enrich the flatpakref with Flathub GPG key when available. | |
| gpg_key="$( | |
| curl -fsSL https://dl.flathub.org/repo/flathub.flatpakrepo \ | |
| | awk -F= '/^GPGKey=/{print substr($0,8); exit}' \ | |
| || true | |
| )" | |
| if [[ -n "$gpg_key" ]]; then | |
| printf 'GPGKey=%s\n' "$gpg_key" >> "$flatpakref_path" | |
| fi | |
| - name: Generate checksums | |
| run: | | |
| cd build/release-assets | |
| find . -type f -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS.txt | |
| - name: Extract changelog for release | |
| id: changelog | |
| env: | |
| TAG_NAME: ${{ github.event.inputs.ref || github.ref_name }} | |
| run: | | |
| set -euo pipefail | |
| tag="${TAG_NAME#refs/tags/}" | |
| if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Invalid tag format: '$tag'. Expected: vX.Y.Z" >&2 | |
| exit 1 | |
| fi | |
| version="${tag#v}" | |
| awk -v version="$version" ' | |
| $0 ~ "^## Version " version " - " { in_section = 1; next } | |
| in_section && $0 ~ "^## Version " { exit } | |
| in_section { print } | |
| ' CHANGELOG.md > release_notes.raw.md | |
| sed '/./,$!d' release_notes.raw.md | tac | sed '/./,$!d' | tac > release_notes.md | |
| if [[ ! -s release_notes.md ]]; then | |
| echo "No changelog entry found for version ${version} in CHANGELOG.md" >&2 | |
| exit 1 | |
| fi | |
| echo "version=${version}" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.ref || github.ref_name }} | |
| draft: true | |
| body_path: release_notes.md | |
| files: | | |
| build/release-assets/**/* |