-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (127 loc) · 5.1 KB
/
build.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build
on: [push, workflow_dispatch]
jobs:
create-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: LinqLover/create-image@master
id: create-image
with:
squeak-version: "6.0"
prepare-script: ./scripts/prepareImage.st
- uses: actions/upload-artifact@master
with:
name: image
path: ${{ steps.create-image.outputs.bundle-path }}
build-screenshots:
needs: create-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@master
with:
name: image
- name: Build screenshots and help
run: |
unzip Squeak*.zip
./squeak.sh -headless $(realpath ./scripts/buildScreenshots.st)
cp -r Squeak*.app/Contents/Resources/screenshots/ .
cp -r Squeak*.app/Contents/Resources/help/ .
- uses: actions/upload-artifact@master
with:
name: screenshots
path: screenshots/
- uses: actions/upload-artifact@master
with:
name: help
path: help/
update-screenshots:
needs:
- build-screenshots
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- run: rm -rf screenshots/ help/
- uses: actions/download-artifact@master
with:
name: screenshots
path: screenshots/
- uses: actions/download-artifact@master
with:
name: help
path: help/
- uses: EndBug/add-and-commit@v9
id: commit
with:
default_author: github_actions
add: screenshots/ help/
message: "Update screenshots/help for ${{ github.sha }}"
push: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-node@v3
if: ${{ steps.commit.outputs.committed == 'true' }} # only required for commit comment below
with:
node-version: 16
- run: |
npm install -g [email protected] # https://github.com/nodegit/nodegit/issues/1840
npm link nodegit
if: ${{ steps.commit.outputs.committed == 'true' }} # only required for commit comment below
- if: ${{ steps.commit.outputs.committed == 'true' }} # no changes -> no commit -> no comment
name: Create commit comment for screenshot/help diff
uses: actions/github-script@v6
with:
script: |
const nodegit = require('nodegit')
const crypto = require('crypto')
const diffId = (diffFile) => crypto.createHash('sha256').update(diffFile.path()).digest('hex')
const repo = await nodegit.Repository.open('.')
const commit = await repo.getCommit('${{ steps.commit.outputs.commit_long_sha }}')
const patches = (await Promise.all((await commit.getDiff()).map(diff => diff.patches()))).flatMap(patch => patch)
const files = patches.map(patch => patch.newFile() ?? patch.oldFile())
const builderUrl = `${{ github.server_url }}/${{ github.repository }}/tree/HEAD/packages/TraceDebuggerJobs.package`
const genericArtifactUrl = `${{ github.server_url }}/${{ github.repository }}/tree/gh-pages`
await github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: `## Changed Screenshots/Help
This push caused [a change of ${files.length} ${files.length === 1 ? 'artifact' : 'artifacts'}](${${{ steps.commit.outputs.pushed }} ? `${{ github.server_url }}/${{ github.repository }}/commit/${commit.sha()}` : builderUrl})${{ steps.commit.outputs.pushed && ' against the default branch' || '' }}:
${files
.map(file =>
`- [${file.path()}](${
${{ steps.commit.outputs.pushed }}
? `${{ github.server_url }}/${{ github.repository }}/commit/${commit.sha()}#diff-${diffId(file)}`
: `${genericArtifactUrl}/${file.path()}`
})`)
.join('\n')}
`,
})
release-image:
needs: create-image
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- id: date
run: echo "::set-output name=date::$(date +'%Y%m%d-%H%M%S')"
- uses: actions/download-artifact@master
with:
name: image
- run: mv Squeak*.zip TraceDebugger-${{ steps.date.outputs.date }}.zip
- uses: softprops/action-gh-release@v1
with:
tag_name: untagged-${{ steps.date.outputs.date }}
body: ${{ github.event.head_commit.message }}
files: TraceDebugger-*.zip
fail_on_unmatched_files: true
prerelease: true
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: dev-drprasad/[email protected]
with:
delete_tag_pattern: untagged-
keep_latest: 2
delete_tags: true
env:
GITHUB_TOKEN: ${{ github.token }}