diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml new file mode 100644 index 0000000..b9118c2 --- /dev/null +++ b/.github/workflows/draft.yml @@ -0,0 +1,67 @@ +name: Draft Release + +on: + workflow_dispatch: + +permissions: + contents: write + +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: | + BRANCH=main + API_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/blank.yml/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 Info + id: info + run: python3 repo/.github/workflow-scripts/get-draft-info.py + - name: Create Draft Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.info.outputs.version }} + name: User Reviews v${{ steps.info.outputs.version }} + body: ${{ steps.info.outputs.cl }} + draft: true + files: | + ./uproxide.more_difficulties.geode