Skip to content

Commit 4a37804

Browse files
committed
GitHub workflow for build WIP
1 parent ab43984 commit 4a37804

File tree

5 files changed

+146
-183
lines changed

5 files changed

+146
-183
lines changed

.github/workflows/build.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: build
2+
on:
3+
push:
4+
branches:
5+
- actionPr
6+
pull_request:
7+
types: [opened, synchronize]
8+
defaults:
9+
run:
10+
shell: bash
11+
env:
12+
publisher: James Teh
13+
concurrency:
14+
# There's no point continuing to run a build if it's already outdated by
15+
# another commit.
16+
group: build-${{ github.ref }}
17+
cancel-in-progress: true
18+
jobs:
19+
build:
20+
strategy:
21+
matrix:
22+
os: [windows-latest, macos-latest]
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- name: set env
26+
run: |
27+
if [ $GITHUB_EVENT_NAME == push ]; then
28+
# For example: 2025.3.7.2011,23631c6e
29+
# We add 1800 to GITHUB_RUN_NUMBER because we can't set the
30+
# starting number and we were already past 1700 on AppVeyor.
31+
echo version=`date +%Y.%-m.%-d`.$((GITHUB_RUN_NUMBER + 1800)),${GITHUB_SHA:0:8} >> "$GITHUB_ENV"
32+
else
33+
# For example: pr1234-23631c6e
34+
echo version=${GITHUB_REF_NAME%%/*}-${GITHUB_SHA:0:8} >> "$GITHUB_ENV"
35+
fi
36+
if [ ${{ matrix.os }} == windows-latest ]; then
37+
echo osName=windows >> "$GITHUB_ENV"
38+
else
39+
echo os=mac >> "$GITHUB_ENV"
40+
fi
41+
- uses: actions/checkout@v4
42+
with:
43+
submodules: true
44+
# There's no point in building if we're going to fail the build because of
45+
# an unsorted key map, so we do this as early as we can.
46+
- name: check key map
47+
run: python tools/sortKeymap.py -t config/${{ env.os }}/reaper-kb.ini
48+
- name: setup
49+
run: pip install scons
50+
# On Mac, we need php for swell_resgen.
51+
- uses: shivammathur/setup-php@v2
52+
if: ${{ matrix.os == 'macos-latest' }}
53+
with:
54+
php-version: 8.4
55+
- name: build
56+
run: scons "publisher=${{ env.publisher }}" version=${{ env.version }}
57+
# We only need to upload the pot on one OS. We arbitrarily pick Windows.
58+
- name: pot
59+
if: ${{ github.event_name == 'push' && matrix.os == 'windows-latest' }}
60+
env:
61+
crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }}
62+
run: |
63+
scons version=${{ env.version }} pot
64+
pip install requests
65+
python ci/crowdinSync uploadPot
66+
# We upload snapshot builds to GitHub Releases so they can be downloaded
67+
# directly rather than being zipped.
68+
- id: uploadBuild
69+
name: upload build
70+
if: ${{ github.event_name == 'push' }}
71+
uses: softprops/action-gh-release@v2
72+
with:
73+
files: installer/osara_*
74+
tag_name: snapshots
75+
- id: getBuildUrl
76+
name: get build URL
77+
if: ${{ github.event_name == 'push' }}
78+
run: |
79+
echo ${{ env.os }}Url=${{ fromJSON(steps.uploadBuild.outputs.assets)[0].browser_download_url }} >> "$GITHUB_OUTPUT"
80+
# We upload pull request builds as normal artifacts.
81+
- name: upload PR build
82+
if: ${{ github.event_name == 'pull_request' }}
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: osara_${{ env.os }}_${{ env.version }}
86+
path: installer/osara_*
87+
compression-level: 0
88+
outputs:
89+
# The version is the same on Windows and Mac. Again, we arbitrarily pick
90+
# Windows to export this.
91+
version: ${{ env.version }}
92+
winInstallerUrl: ${{ steps.getBuildUrl.outputs.windowsUrl }}
93+
macInstallerUrl: ${{ steps.getBuildUrl.outputs.macUrl }}
94+
publish:
95+
# This job updates the website with the new readme and snapshots.
96+
if: ${{ github.event_name == 'push' }}
97+
needs: build
98+
runs-on: ubuntu-latest
99+
permissions:
100+
pages: write
101+
id-token: write
102+
steps:
103+
- name: setup
104+
run: pip install markdown
105+
- uses: actions/checkout@v4
106+
- name: build
107+
env:
108+
version: ${{ needs.build.outputs.version }}
109+
winUrl: ${{ needs.build.outputs.winInstallerUrl }}
110+
macUrl: ${{ needs.build.outputs.macInstallerUrl }}
111+
run: python ci/buildSite
112+
- name: upload
113+
uses: actions/upload-pages-artifact@v3
114+
with:
115+
# ci/buildSite builds the site in _site/.
116+
path: _site/
117+
- name: deploy
118+
uses: actions/deploy-pages@v4

appveyor.yml

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/python3
22

33
# OSARA: Open Source Accessibility for the REAPER Application
4-
# CI server script to publish OSARA snapshots
5-
# Copyright 2016-2024 NV Access Limited, James Teh
4+
# CI script to build the OSARA website, including the snapshots page and update
5+
# data.
6+
# Copyright 2016-2025 NV Access Limited, James Teh
67
# License: GNU General Public License version 2.0
78

89
import sys
@@ -12,21 +13,13 @@ import datetime
1213
import urllib.request
1314
import markdown
1415

15-
SNAPSHOT_INDEX_DIR = os.path.expanduser("~osara/data/snapshotIndex")
16-
SNAPSHOTS_DIR = os.path.expanduser("~osara/www/main/snapshots")
16+
SITE_DIR = "_site"
17+
SNAPSHOTS_DIR = os.path.join(SITE_DIR, "snapshots")
1718
SNAPSHOT_INDEX_FILE = os.path.join(SNAPSHOTS_DIR, "index.html")
1819
UPDATE_FILE = os.path.join(SNAPSHOTS_DIR, "update.json")
19-
README_URL = "https://github.com/jcsteh/osara/raw/master/readme.md"
20-
README_FILE = os.path.expanduser("~osara/www/main/index.html")
20+
README_FILE = os.path.join(SITE_DIR, "index.html")
2121

22-
def getData(buildOs):
23-
fn = os.path.join(SNAPSHOT_INDEX_DIR, buildOs)
24-
try:
25-
return json.load(open(fn))
26-
except IOError:
27-
return None
28-
29-
def writeSnapshotIndex(winData, macData):
22+
def writeSnapshotIndex(data):
3023
print("Writing snapshot index")
3124
with open(SNAPSHOT_INDEX_FILE, "w") as f:
3225
f.write("<html>\n"
@@ -39,30 +32,15 @@ def writeSnapshotIndex(winData, macData):
3932
'<p>Be aware that technically, OSARA has not yet had an official release. That said, the extension can safely be considered stable. At this point, OSARA is being used every day in production by people all over the world.</p>\n'
4033
'<p>If you find a bug, please <a href="https://github.com/jcsteh/osara/issues/new">open a new issue on GitHub</a> and describe the problem, preferably with thorough steps to reproduce the issue, what happened and what you expected to happen instead.</p>\n'
4134
'<p>Support requests should be posted on the <a href="https://groups.io/g/rwp">Reapers Without Peepers (RWP) group</a>.</p>\n'
42-
"<ul>\n")
43-
if winData:
44-
winData["osName"] = "Windows"
45-
if macData:
46-
macData["osName"] = "Mac"
47-
for data in winData, macData:
48-
if not data:
49-
continue
50-
f.write(
51-
'<li><a href="https://ci.appveyor.com/api/buildjobs/{data[jobId]}/artifacts/installer/{data[installer]}">Download OSARA for {data[osName]}, version {data[version]}</a> ({data[date]})</li>\n'
52-
.format(data=data))
53-
if winData.get("pot"):
54-
f.write(
55-
'<li><a href="https://ci.appveyor.com/api/buildjobs/{data[jobId]}/artifacts/locale/{data[pot]}">Download gettext template for translators {data[version]}</a></li>\n'
56-
.format(data=winData))
57-
if winData.get("commit"):
58-
f.write(
59-
'<li><a href="https://github.com/jcsteh/osara/commits/{data[commit]}">Change log</a></li>\n'
60-
.format(data=winData))
61-
62-
f.write(
35+
"<ul>\n"
36+
'<li>Version {data[version]}, {data[date]}</li>\n'
37+
'<li><a href="{data[winUrl]}">Download for Windows</a></li>\n'
38+
'<li><a href="{data[macUrl]}">Download for Mac</a></li>\n'
39+
'<li><a href="https://github.com/jcsteh/osara/commits/{data[commit]}">Change log</a></li>\n'
6340
"</ul>\n"
6441
"</body>\n"
65-
"</html>\n")
42+
"</html>\n"
43+
.format(data=data))
6644

6745
def getCommits():
6846
with urllib.request.urlopen(
@@ -81,9 +59,8 @@ def writeUpdateData(data):
8159
json.dump(out, f)
8260

8361
def updateReadme():
84-
print("Downloading readme")
85-
with urllib.request.urlopen(README_URL) as req:
86-
bodyMd = req.read().decode('UTF-8')
62+
print("Rendering readme")
63+
bodyMd = open("readme.md", "rt", encoding="utf-8").read()
8764
bodyHtml = markdown.markdown(bodyMd)
8865
print("Writing readme")
8966
with open(README_FILE, "w") as f:
@@ -97,25 +74,18 @@ def updateReadme():
9774
f.write('\n</body>\n</html>\n')
9875

9976
def main():
100-
data = json.loads(sys.stdin.readline())
101-
data["date"] = datetime.datetime.now(datetime.UTC).ctime()
102-
buildOs = data["os"]
103-
if not buildOs.isalpha():
104-
raise ValueError
105-
print("Publishing %s snapshot %s" % (buildOs, data["version"]))
106-
json.dump(data,
107-
open(os.path.join(SNAPSHOT_INDEX_DIR, buildOs), "w"))
108-
if buildOs == "win":
109-
winData = data
110-
macData = getData("mac")
111-
else:
112-
macData = data
113-
winData = getData("win")
114-
115-
writeSnapshotIndex(winData, macData)
116-
if buildOs == "win":
117-
writeUpdateData(winData)
118-
updateReadme()
77+
os.makedirs(SNAPSHOTS_DIR)
78+
data = {
79+
"commit": os.getenv("GITHUB_SHA"),
80+
"version": os.getenv("version"),
81+
"winUrl": os.getenv("winUrl"),
82+
"macUrl": os.getenv("macUrl"),
83+
"date": datetime.datetime.now(datetime.UTC).ctime(),
84+
}
85+
print("Publishing snapshots for {data[version]}".format(data=data))
86+
writeSnapshotIndex(data)
87+
writeUpdateData(data)
88+
updateReadme()
11989

12090
if __name__ == "__main__":
12191
main()

ci/ssh_id_rsa.enc

-1.66 KB
Binary file not shown.

ci/ssh_known_hosts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)