-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (144 loc) · 4.93 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
138
139
140
141
142
143
144
145
146
147
148
149
name: build
on:
workflow_dispatch:
inputs:
branch:
description: 'The branch to build'
required: true
default: 'main'
tag_version:
description: 'The version of pxt-ev3 upstream, eg: use 1.4.36 instead of v1.4.36'
required: true
default: '1.4.36'
# https://docs.github.com/zh/actions/using-jobs/assigning-permissions-to-jobs
permissions: write-all
# permissions:
# pull-requests: write
# contents: write
# repository-projects: write
env:
APP_NAME: pxt-ev3-app
defaults:
run:
shell: bash
jobs:
build-depolyable-static-files:
name: Build depoly files for ${{ github.event.inputs.tag_version }}
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
submodules: true
- name: 'Checkout and push specified tag version of scratch'
run: |
git config --global pull.rebase false
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
cd pxt-ev3
git status
git remote -v
git fetch --all --tags
git checkout tags/v${{ github.event.inputs.tag_version }}
git status
cd ..
git add pxt-ev3
git commit -m "update pxt-ev3 to v${{ github.event.inputs.tag_version }}" || true
# update version in README.md using sed
sed -i "s/[0-9]\+\.[0-9]\+\.[0-9]\+/${{ github.event.inputs.tag_version }}/g" README.md
git add README.md
git commit -m "update README.md" || true
git tag ${{ github.event.inputs.tag_version }} || true
git push
git push --tag
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'npm'
- name: 'Initialization'
run: |
sudo apt-get install xvfb
sudo npm install -g pxt
npm install
working-directory: pxt-ev3
# - name: 'Patching...'
# run: |
# # try to fix staticpkg failure when process homepage-content.md
# # TypeError: Cannot read properties of undefined (reading 'replace')
# # The fix is change the fallback returns of resolveMd to targetMd
# sed -i -z -E 's#(function resolveMd.*?)return undefined;#\1return targetMd;#g' node_modules/pxt-core/built/nodeutil.js
# working-directory: pxt-ev3
- name: 'Building pxt-ev3'
run: |
node node_modules/pxt-core/built/pxt.js staticpkg
working-directory: pxt-ev3
- name: Prepare build files achive
run: |
ls -lR ./pxt-ev3/built/
7z a -tzip ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip -r ./pxt-ev3/built/packaged/*
- uses: actions/upload-artifact@v4
with:
name: pxt-ev3-dist
path: ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip
- name: Publish build files achive to release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.event.inputs.tag_version }}
files: ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip
draft: false
prerelease: false
build-native-executable:
name: 'Build native executable'
needs: [build-depolyable-static-files]
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
runs-on: ${{matrix.os}}
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: pxt-ev3-dist
- name: Extract pxt-ev3-dist
run: |
rm -rf dist
unzip ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip -d dist
- name: Display structure of downloaded files
run: ls -l . dist
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'yarn'
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Tauri build
id: tauri-build
uses: liudonghua123/tauri-build-action@main
with:
project_name: ${{env.APP_NAME}}
identifier: com.${{env.APP_NAME}}.app
version: ${{ github.event.inputs.tag_version }}
frontend_dist: ../dist
icon: app-icon.png
- name: Display structure of build files
run: |
ls -la . tauri-build
shell: bash
- name: Publish binary to release
continue-on-error: true
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.event.inputs.tag_version }}
files: tauri-build/*
draft: false
prerelease: false