Skip to content

(Release): Build

(Release): Build #2

Workflow file for this run

name: "(Release): Build"
on:
release:
types: [created]
permissions:
contents: read
actions: read
jobs:
build:
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.event.release.tag_name }}
upload:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
zip_name: ${{ steps.zip.outputs.zip_name }}
steps:
- name: Download built zip
id: download
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.build.outputs.artifact_id }}
path: ./bundle
- name: Create zip archive
id: zip
run: |
# zip filename format: <artifact_name>.<tag_name>.zip
zip_name="${{ needs.build.outputs.artifact_name }}.${{ github.event.release.tag_name }}.zip"
cd ./bundle/${{ needs.build.outputs.artifact_name }}
zip -r "../$zip_name" .
cd ..
echo "zip_name=$zip_name" >> $GITHUB_OUTPUT
echo "path=$(pwd)/$zip_name" >> $GITHUB_OUTPUT
- name: Upload release asset
id: upload
uses: codesnippetspro/action-gh-release@master
with:
files: ${{ steps.zip.outputs.path }}
deploy:
needs: [build, upload]
runs-on: ubuntu-latest
steps:
- name: Dispatch publish workflow
env:
GH_TOKEN: ${{ secrets.CHANGELOG_PAT }}
run: |
target_repo="codesnippetspro/.github-private"
workflow_file="publish.yml"
echo "::notice::Dispatching publish workflow..."
echo " Repository: $target_repo"
echo " Source Repo: ${{ github.repository }}"
echo " Branch: ${{ github.ref_name }}"
echo " Tag: ${{ github.event.release.tag_name }}"
echo " Artifact Name: ${{ needs.build.outputs.artifact_name }}"
# Dispatch the workflow with required parameters
if ! gh workflow run "$workflow_file" \
--repo "$target_repo" \
--ref main \
--field repo="${{ github.repository }}" \
--field branch="${{ github.ref_name }}" \
--field tag="${{ github.event.release.tag_name }}" \
--field zip_name="${{ needs.upload.outputs.zip_name }}"; then
echo "::error::Failed to dispatch publish workflow in $target_repo"
exit 1
fi
echo "::notice::Successfully dispatched publish workflow"
# Wait a moment for the run to be created
echo "Waiting for workflow run to be created..."
sleep 10
# Get the workflow run URL for monitoring
if run_url=$(gh run list --repo "$target_repo" --workflow "$workflow_file" --limit 1 --json url -q '.[0].url' 2>/dev/null); then
echo "::notice::Monitor workflow progress at: $run_url"
echo "workflow_url=$run_url" >> $GITHUB_OUTPUT
fi