Draft Release #6
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: Draft Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
buildWorkflowOverride: | ||
description: 'Build Workflow [Overrides the default]' | ||
required: false | ||
type: string | ||
env: | ||
Build_Workflow: build.yml | ||
jobs: | ||
draft: | ||
name: Draft | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
path: repo | ||
- name: Define variables | ||
id: defvar | ||
run: | | ||
Check failure on line 26 in .github/workflows/draft.yml GitHub Actions / Draft ReleaseInvalid workflow file
|
||
BRANCH=${GITHUB_REF#refs/heads/} | ||
API_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ inputs.buildWorkflowOverride == "" ? env.Build_Workflow : inputs.buildWorkflowOverride }}/runs?per_page=1&branch=$BRANCH&status=success" | ||
RUN_ID=$(curl $API_URL | jq .workflow_runs[0].id) | ||
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT | ||
- name: Download artifacts | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('node:fs/promises'); | ||
const path = `${process.env.GITHUB_WORKSPACE}/artifacts`; | ||
await fs.mkdir(path, { recursive: true }); | ||
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{ steps.defvar.outputs.run_id }}, | ||
}); | ||
console.log(`Found ${allArtifacts.data.artifacts.length} artifacts!`); | ||
for (const artifact of allArtifacts.data.artifacts) { | ||
console.log(`Downloading ${artifact.name}`); | ||
const download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: artifact.id, | ||
archive_format: 'zip', | ||
}); | ||
await fs.writeFile(`${path}/${artifact.name}.zip`, Buffer.from(download.data)); | ||
} | ||
- name: Unzip Build | ||
run: | | ||
7z x "./artifacts/Build Output.zip" -o"./" | ||
- name: Get Mod ID | ||
id: getmodid | ||
run: | | ||
for filename in *; do | ||
if [[ "$filename" == *.geode ]]; then | ||
echo "modid=${filename%.geode}" >> GITHUB_OUTPUT | ||
break | ||
fi | ||
done | ||
- name: Get Info | ||
id: info | ||
run: python3 repo/.github/workflow-scripts/get-info.py | ||
env: | ||
modid: ${{ steps.getmodid.outputs.modid }} | ||
- name: Create Draft Release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: Release-v${{ steps.info.outputs.version }} | ||
name: Click Sounds v${{ steps.info.outputs.version }} for Geode | ||
body: ${{ steps.info.outputs.cl }} | ||
draft: true | ||
files: | | ||
./${{ steps.getmodid.outputs.modid }}.geode |