forked from xpf0000/FlyEnv
-
Notifications
You must be signed in to change notification settings - Fork 2
157 lines (139 loc) · 4.78 KB
/
build-linux.yml
File metadata and controls
157 lines (139 loc) · 4.78 KB
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
150
151
152
153
154
155
156
157
name: Build FlyEnv • Linux
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag version để build (ví dụ: v1.2.3). Bỏ trống = build từ branch dev'
required: false
default: ''
permissions:
contents: write
jobs:
build:
name: Build FlyEnv Linux • ${{ github.event.inputs.tag || 'dev' }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
matrix:
include:
- arch: x64
os: ubuntu-22.04
target: x64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || 'refs/heads/dev' }}
- name: Setup Node.js (LTS)
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup Go Lang
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache-dependency-path: src/helper-go/go.sum
- name: Install build deps (Linux)
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
python3 \
python3-pip \
pkg-config \
fakeroot \
rpm \
dpkg-dev \
debhelper
python3 -m pip install --upgrade pip
- name: Cache node-gyp & yarn cache
uses: actions/cache@v4
with:
path: |
~/.cache/node-gyp
~/.yarn
.yarn/cache
node_modules
**/node_modules
key: ${{ runner.os }}-${{ matrix.arch }}-yarn-${{ hashFiles('**/package.json') }}
- name: Install Yarn & tools
run: |
npm -g install yarn node-gyp
yarn --version
node -v
go version
- name: Install dependencies
run: yarn install
- name: Build Go helper Linux
shell: bash
working-directory: src/helper-go
env:
GOARCH: ${{ matrix.arch == 'x64' && 'amd64' || matrix.arch == 'arm64' && 'arm64' || 'amd64' }}
run: |
go mod tidy
chmod +x ./build-os.sh
./build-os.sh
- name: Prepare arch env for electron build
run: |
if [ "${{ matrix.arch }}" = "x64" ]; then
echo "ELECTRON_ARCH=x64" >> $GITHUB_ENV
echo "GOARCH=amd64" >> $GITHUB_ENV
else
echo "ELECTRON_ARCH=arm64" >> $GITHUB_ENV
echo "GOARCH=arm64" >> $GITHUB_ENV
fi
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Build Electron packages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ELECTRON_BUILDER_ARCH: ${{ env.ELECTRON_ARCH }}
run: |
yarn build
- name: Show release folder (debug)
run: |
echo "Release files:"
ls -la release || true
find release -maxdepth 1 -type f -print || true
- name: Check tag existence on remote
id: check_tag
run: |
TAG="${{ github.event.inputs.tag }}"
# default outputs
echo "tag_provided=false" >> $GITHUB_OUTPUT
echo "tag_exists=false" >> $GITHUB_OUTPUT
if [ -z "$TAG" ]; then
echo "No tag provided (input empty). Will upload artifacts for manual download."
exit 0
fi
echo "Tag provided: $TAG"
# fetch tags from origin and check
git fetch --tags origin
if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then
echo "tag_provided=true" >> $GITHUB_OUTPUT
echo "tag_exists=true" >> $GITHUB_OUTPUT
echo "Found tag $TAG on repo."
else
echo "tag_provided=true" >> $GITHUB_OUTPUT
echo "tag_exists=false" >> $GITHUB_OUTPUT
echo "Tag $TAG not found on repo. Will upload artifacts for manual download."
fi
# If tag provided and exists -> attach to release (create/update release by tag)
- name: Upload artifacts to GitHub Release (tag exists)
if: steps.check_tag.outputs.tag_provided == 'true' && steps.check_tag.outputs.tag_exists == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
files: |
release/*.deb
release/*.rpm
release/*.blockmap
release/latest-linux.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Otherwise upload as workflow artifacts for manual download
- name: Upload artifacts for manual download (no tag)
if: steps.check_tag.outputs.tag_provided != 'true' || steps.check_tag.outputs.tag_exists != 'true'
uses: actions/upload-artifact@v4
with:
name: flyenv-linux-${{ matrix.arch }}-release
path: release/*