Skip to content

AppendRelease

AppendRelease #168

# After a release is successfully published, upload extra assets to it
name: AppendRelease
# We're going to edit a gh release, so we need that permission
permissions:
contents: write
on:
# Whenever a workflow called "Release" completes, run this!
workflow_run:
workflows: ["Release"]
types:
- completed
jobs:
# Check if we should actually run by looking for the should-publish job
should-run:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
val: ${{ steps.check.outputs.result }}
steps:
- id: check
uses: actions/github-script@v6
with:
result-encoding: string
script: |
let allRuns = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
for (const job of allRuns.data.jobs) {
if (job.name == "should-publish") {
if (job.status == "completed" && job.conclusion == "success") {
return "run"
}
}
}
return "skip"
# Generate dist-manifest-schema.json and upload it to the release
schema:
name: Add schema to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
needs: ["should-run"]
if: ${{ needs.should-run.outputs.val == 'run' }}
steps:
# Setup
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
# We get the tag of the release in github.event.workflow_run.head_branch
# No idea why it's stored there with that name, but, it is?
- name: Install cargo-dist and upload schema
run: |
echo "uploading schema to ${{ github.event.workflow_run.head_branch }}"
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/${{ github.event.workflow_run.head_branch }}/cargo-dist-installer.sh | sh
cargo dist manifest-schema > dist-manifest-schema.json
gh release upload ${{ github.event.workflow_run.head_branch }} dist-manifest-schema.json