Merge pull request #713 from tier4/sync-awf-upstream #166
Workflow file for this run
This file contains 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
# This file is automatically synced from: | |
# https://github.com/autowarefoundation/sync-file-templates | |
# To make changes, update the source repository and follow the guidelines in its README. | |
name: github-release | |
on: | |
push: | |
branches: | |
- beta/v* | |
tags: | |
- v* | |
workflow_dispatch: | |
inputs: | |
beta-branch-or-tag-name: | |
description: The name of the beta branch or tag to release | |
type: string | |
required: true | |
jobs: | |
github-release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Set tag name | |
id: set-tag-name | |
run: | | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
REF_NAME="${{ github.event.inputs.beta-branch-or-tag-name }}" | |
else | |
REF_NAME="${{ github.ref_name }}" | |
fi | |
echo "ref-name=$REF_NAME" >> $GITHUB_OUTPUT | |
echo "tag-name=${REF_NAME#beta/}" >> $GITHUB_OUTPUT | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ steps.set-tag-name.outputs.ref-name }} | |
- name: Set target name for beta branches | |
id: set-target-name | |
run: | | |
if [[ "${{ steps.set-tag-name.outputs.ref-name }}" =~ "beta/" ]]; then | |
echo "target-name=${{ steps.set-tag-name.outputs.ref-name }}" >> $GITHUB_OUTPUT | |
fi | |
- name: Create a local tag for beta branches | |
run: | | |
if [ "${{ steps.set-target-name.outputs.target-name }}" != "" ]; then | |
git tag "${{ steps.set-tag-name.outputs.tag-name }}" | |
fi | |
- name: Run generate-changelog | |
id: generate-changelog | |
uses: autowarefoundation/autoware-github-actions/generate-changelog@v1 | |
- name: Select verb | |
id: select-verb | |
run: | | |
has_previous_draft=$(gh release view --json isDraft -q ".isDraft" "${{ steps.set-tag-name.outputs.tag-name }}") || true | |
verb=create | |
if [ "$has_previous_draft" = "true" ]; then | |
verb=edit | |
fi | |
echo "verb=$verb" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release to GitHub | |
run: | | |
gh release ${{ steps.select-verb.outputs.verb }} "${{ steps.set-tag-name.outputs.tag-name }}" \ | |
--draft \ | |
--target "${{ steps.set-target-name.outputs.target-name }}" \ | |
--title "Release ${{ steps.set-tag-name.outputs.tag-name }}" \ | |
--notes "$NOTES" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NOTES: ${{ steps.generate-changelog.outputs.changelog }} |