publish_release #12
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
name: publish_release | |
on: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
inputs: | |
commit_id: | |
description: 'Commit ID (required for manual trigger)' | |
required: true | |
jobs: | |
publish_packages: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Find CI workflow run by commit ID | |
id: find_workflow | |
run: | | |
if [ "${{ github.event_name }}" == "release" ]; then | |
commit_id="${{ github.event.release.target_commitish }}" | |
else | |
commit_id="${{ github.event.inputs.commit_id }}" | |
fi | |
if [ -z "$commit_id" ]; then | |
echo "Error: commit_id is empty." | |
exit 1 | |
fi | |
echo "Commit ID: ${commit_id}" | |
workflow_runs=$(gh api -X GET "/repos/${{ github.repository }}/actions/runs?event=push&status=success" -q '.workflow_runs | map(select(.head_commit.id == "'"${commit_id}"'")) | sort_by(.created_at) | reverse | .[0]') | |
run_id=$(echo "$workflow_runs" | jq -r '.id') | |
echo "Run ID: ${run_id}" | |
echo "run_id=${run_id}" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download npm artifact | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ env.run_id }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
name: npm | |
path: bld/npm |