Skip to content

github-release

github-release #7

Workflow file for this run

# 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:
tags:
- "*.*.*"
workflow_dispatch:
inputs:
tag-name:
description: The name of the 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.tag-name }}"
else
REF_NAME="${{ github.ref_name }}"
fi
echo "tag-name=$REF_NAME" >> $GITHUB_OUTPUT
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.set-tag-name.outputs.tag-name }}
- name: Run generate-changelog
id: generate-changelog
uses: autowarefoundation/autoware-github-actions/generate-changelog@v1
with:
git-cliff-args: |
--tag-pattern "^(\d+)\.(\d+)\.(\d+)$"
--latest
- 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 \
--title "Release ${{ steps.set-tag-name.outputs.tag-name }}" \
--notes "$NOTES"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTES: ${{ steps.generate-changelog.outputs.changelog }}