-
Notifications
You must be signed in to change notification settings - Fork 81
68 lines (60 loc) · 2.26 KB
/
publish-artifacts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Publish Build Artifacts
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [master]
jobs:
check-publishing-enabled:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
SHOULD_PUBLISH: ${{ steps.check.outputs.SHOULD_PUBLISH }}
steps:
- name: Check if publishing is enabled
id: check
run: echo "SHOULD_PUBLISH=${{ env.PUBLISH_ENABLED != ''}}" >> $GITHUB_OUTPUT
env:
PUBLISH_ENABLED: ${{ vars.ENABLE_PRERELEASE_ARTIFACT_PUBLISHING }}
publish-artifacts:
runs-on: ubuntu-latest
needs: [check-publishing-enabled]
if: needs.check-publishing-enabled.outputs.SHOULD_PUBLISH == 'true'
steps:
- uses: actions/checkout@v3
- run: |
mkdir artifacts
echo "updated_on=$(/bin/date -u '+%Y-%m-%d %H:%M')" >> $GITHUB_ENV
- name: Download Build Artifacts
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
await Promise.all(allArtifacts.data.artifacts.map(async function(art) {
if (art.name.match(/-debug/)) return; // Skip debug artifacts
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: art.id,
archive_format: 'zip',
});
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/artifacts/${art.name}.zip`, Buffer.from(download.data));
}));
- name: Delete Previous Tag
run: |
git tag -d last-successful || true
git push origin :refs/tags/last-successful || true
- name: Update Release
id: release
uses: softprops/action-gh-release@v0.1.15
with:
prerelease: true
tag_name: last-successful
name: "Last successful build (unstable)"
files: 'artifacts/*.zip'
body_path: '.github/PRERELEASE_NOTES.md'