Create github release #401
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: Create github release | |
on: | |
push: | |
tags: | |
- "@dojoengine/*@*" | |
workflow_run: | |
workflows: ["Publish packages and create tags"] | |
types: | |
- completed | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Given github tag to create release for" | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
release: | |
name: Release pushed tag | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get latest tags | |
if: ${{ github.event_name == 'workflow_run' }} | |
id: latest-tags | |
run: scripts/get-latest-tags.sh | |
- name: Create releases for workflow_run | |
if: ${{ github.event_name == 'workflow_run' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Process each recent tag | |
while IFS= read -r tag; do | |
if [ -n "$tag" ]; then | |
# Check if release already exists | |
if gh release view "$tag" >/dev/null 2>&1; then | |
echo "Release $tag already exists, skipping..." | |
else | |
echo "Creating release for $tag" | |
gh release create "$tag" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="${tag#v}" \ | |
--generate-notes | |
fi | |
fi | |
done < recent_tags.txt | |
- name: Create release for single tag | |
if: ${{ github.event_name != 'workflow_run' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} | |
run: | | |
# Check if release already exists | |
if gh release view "$tag" >/dev/null 2>&1; then | |
echo "Release $tag already exists, skipping..." | |
else | |
gh release create "$tag" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="${tag#v}" \ | |
--generate-notes | |
fi | |