forked from H-uru/Plasma
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (73 loc) · 2.71 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- run: |
mkdir artifacts
echo "updated_on=$(/bin/date -u '+%Y-%m-%d %H:%M')" >> $GITHUB_ENV
- name: Download Build Artifacts
uses: actions/github-script@v7
with:
script: |
const fs = require('node: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: Get release body text
id: read_release
shell: bash
run: |
r=$(cat .github/PRERELEASE_NOTES.md)
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
r="${r//@@COMMIT_SHA@@/$GITHUB_SHA}"
echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT
env:
GITHUB_SHA: ${{ github.sha }}
- name: Update Release
id: release
uses: svenstaro/upload-release-action@v2
with:
prerelease: true
overwrite: true
tag: last-successful
release_name: "Last successful build (unstable)"
file_glob: true
file: artifacts/*.zip
body: |
${{ steps.read_release.outputs.RELEASE_BODY }}