Files
llvm-mingw/.github/workflows/release.yml
T
Martin Storsjö 7b53b4af23 github: Fix specifying a commit rather than a branch for manual jobs
As the branch field has a default value "master", this default
not only applies when the dialog box for starting the manual
workflow is presented. But even if the prefilled branch field
is cleared, the default value also gets substituted when submitting.

In this case, when the commit and branch fields are mutually
exclusive, we can't easily have a default. Instead change the
uses of the fields, ignoring the branch field if the commit field
is filled.

If the dawidd6/action-download-artifact action would support
specifying either a commit or a branch in the same field, like
actions/checkout does, we wouldn't need this distinction at all;
this request is tracked upstream at
https://github.com/dawidd6/action-download-artifact/issues/242.
2025-05-29 17:27:53 +03:00

92 lines
3.0 KiB
YAML

name: Make a release, upload artifacts
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit to extract from'
type: string
branch:
description: 'Branch to extract from'
type: string
default: 'master'
tag:
description: 'Tag to create/upload to'
required: true
type: string
title:
description: 'Release title'
type: string
make_tag:
description: 'Make a tag'
type: boolean
default: true
create_release:
description: 'Create release'
type: boolean
default: true
prerelease:
description: 'Set as pre-release'
type: boolean
default: false
permissions:
contents: read
jobs:
upload-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
workflow_conclusion: success
commit: ${{inputs.commit}}
branch: ${{inputs.commit == '' && inputs.branch || ''}}
event: push
- name: Rearrange files
run: |
rm -rf linux-asserts*
rm -rf msys2*
mv *-toolchain/*.zip *-toolchain/*.tar.xz .
- name: Set environment
run: |
cat parameters/parameters.txt >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
path: repo
- name: Make a tag
if: ${{inputs.make_tag}}
run: |
if [ "$TAG" != "${{inputs.tag}}" ]; then
echo Tag mismatch, \"$TAG\" in workflow vs \"${{inputs.tag}}\" as input
exit 1
fi
cd repo
git config --global user.name "GitHub Actions"
git config --global user.email martin@martin.st
git tag -a ${{inputs.tag}} -m "${{inputs.title}}"
# If the commit isn't the tip of a branch, and there are
# differences in workflow files compared with the tip of the
# branch, GitHub rejects this push with "refusing to allow a
# GitHub App to create or update workflow
# `.github/workflows/build.yml` without `workflows` permission".
# In such cases, manually create and push the tag and rerun with
# make_tag set to false.
git push origin ${{inputs.tag}}
- name: Create release and upload binaries
env:
GITHUB_TOKEN: ${{github.token}}
run: |
if ${{inputs.prerelease}}; then
prerelease="--prerelease"
fi
if ${{inputs.create_release}}; then
gh release create ${{inputs.tag}} --verify-tag $prerelease --title "${{inputs.title}}" --notes "" *.tar.xz *.zip -R ${{github.repository}}
else
gh release upload ${{inputs.tag}} *.tar.xz *.zip --clobber -R ${{github.repository}}
fi