Release #86
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: Release | |
on: | |
workflow_run: | |
workflows: [ Build and test ] | |
types: [ completed ] | |
branches: [ master ] | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check version | |
run: (tools/version -C && echo "RELEASE=1" || echo "RELEASE=") >> "$GITHUB_ENV" | |
- name: Check if release already exists | |
if: ${{env.RELEASE == '1'}} | |
run: | | |
set +o errexit | |
(env DRY_RUN=1 .github/release && RC=$?) || RC=$? | |
if [ "$RC" -eq 2 ]; then | |
echo "RELEASE=0" >> "$GITHUB_ENV" | |
elif [ "$RC" -neq 0 ]; then | |
exit "$RC" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create artifacts directory | |
if: ${{env.RELEASE == '1'}} | |
run: | | |
ARTIFACTS=$GITHUB_WORKSPACE/artifacts | |
mkdir -p "$ARTIFACTS" | |
echo "ARTIFACTS=$ARTIFACTS" >> "$GITHUB_ENV" | |
- name: Download artifacts | |
if: ${{env.RELEASE == '1'}} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchedArtifacts = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name.startsWith("PKGBUILD") || artifact.name.startsWith("source-package") | |
}); | |
let fs = require('fs'); | |
for(const artifact of matchedArtifacts) { | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: artifact.id, | |
archive_format: 'zip', | |
}); | |
console.log(`${process.env.ARTIFACTS}/${artifact.name}.zip`) | |
fs.writeFileSync(`${process.env.ARTIFACTS}/${artifact.name}.zip`, Buffer.from(download.data)); | |
} | |
- name: Create release | |
if: ${{env.RELEASE == '1'}} | |
run: .github/release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |