Skip to content

Create Release and Attach Artifacts #10

Create Release and Attach Artifacts

Create Release and Attach Artifacts #10

Workflow file for this run

name: Create Release and Attach Artifacts
on:
push:
tags:
- "v*.*.*" # Trigger when a tag with this format is pushed
workflow_dispatch:
inputs:
tag_name:
description: "Tag name for the release (e.g., v1.2.3)"
required: false
default: ""
jobs:
create-release:
name: Create GitHub Release and Attach Artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Determine Tag Name
id: determine_tag
run: |
if [[ "${{ github.event.inputs.tag_name }}" != "" ]]; then
echo "::set-output name=tag_name::${{ github.event.inputs.tag_name }}"
elif [[ "${{ github.ref }}" != "" ]]; then
echo "::set-output name=tag_name::${{ github.ref_name }}"
else
echo "Error: No tag name provided." >&2
exit 1
fi
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: ${{ steps.determine_tag.outputs.tag_name }}
- uses: ./.github/actions/build_package
with:
python-version: "3.9"
- name: Check Release Existence
id: check_release
run: |
if gh release view ${{ steps.determine_tag.outputs.tag_name }} >/dev/null 2>&1; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Delete Current Release
id: delete_release
if: steps.check_release.outputs.exists == 'ture'
run: |
gh release delete ${{ steps.determine_tag.outputs.tag_name }} -y
- name: Create GitHub Release
id: create_release
run: |
gh release create ${{ steps.determine_tag.outputs.tag_name }} ./dist/* \
--title "${{ steps.determine_tag.outputs.tag_name }}" \
--notes "🎉 New release: ${{ steps.determine_tag.outputs.tag_name }}" \
--draft=false \
--prerelease=false
env:
GH_TOKEN: ${{ github.token }}