Skip to content

Commit 1f7411a

Browse files
committed
provide officially built macOS packages
1 parent a739498 commit 1f7411a

6 files changed

Lines changed: 221 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build backend file for macOS
2+
3+
inputs:
4+
go-version:
5+
required: false
6+
description: "The Go version to use for building the macOS backend. The version should be in the format of 'x.y.z'."
7+
default: "1.26.2"
8+
release-build:
9+
required: false
10+
description: "Whether to build the macOS backend in release mode. If set to '1', the backend will be built in release mode. Otherwise, it will be built in development mode."
11+
build-unix-time:
12+
required: false
13+
description: "The unix time to use for building the macOS backend. The value should be a string representing the unix time in seconds."
14+
build-date:
15+
required: false
16+
description: "The date to use for building the macOS backend. The value should be a string representing the date in the format of 'YYYYMMDD'."
17+
check-3rd-api:
18+
required: false
19+
description: "Whether to run integration tests that call third party APIs. If set to '1', the tests will be run. Otherwise, the tests will be skipped."
20+
skip-tests:
21+
required: false
22+
description: "Whether to skip tests when building the macOS backend. If set to '1', the tests will be skipped. Otherwise, the tests will be run."
23+
architecture:
24+
required: true
25+
description: "The name of the architecture to build the macOS package for."
26+
backend-artifact-name-prefix:
27+
required: true
28+
description: "The prefix for the macOS backend artifact name."
29+
30+
runs:
31+
using: "composite"
32+
steps:
33+
- name: Set up Go
34+
uses: actions/setup-go@v6
35+
with:
36+
go-version: ${{ inputs.go-version }}
37+
38+
- name: Build backend for macOS-${{ inputs.architecture }}
39+
shell: bash
40+
env:
41+
RELEASE_BUILD: "${{ inputs.release-build }}"
42+
BUILD_PIPELINE: "1"
43+
BUILD_UNIXTIME: "${{ inputs.build-unix-time }}"
44+
BUILD_DATE: "${{ inputs.build-date }}"
45+
CHECK_3RD_API: "${{ inputs.check-3rd-api }}"
46+
SKIP_TESTS: "${{ inputs.skip-tests }}"
47+
run: |
48+
./build.sh backend
49+
50+
- name: Upload macOS-${{ inputs.architecture }} backend artifact
51+
uses: actions/upload-artifact@v7
52+
with:
53+
name: ${{ inputs.backend-artifact-name-prefix }}-macos-${{ inputs.architecture }}
54+
path: ezbookkeeping
55+
if-no-files-found: error
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build packages for macOS
2+
3+
inputs:
4+
architecture:
5+
required: true
6+
description: "The name of the architecture to build the macOS package for."
7+
package-file-name-prefix:
8+
required: true
9+
description: "The prefix for the macOS package file name."
10+
backend-artifact-name-prefix:
11+
required: true
12+
description: "The prefix for the macOS backend artifact name."
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Download macOS-${{ inputs.architecture }} backend file
18+
uses: actions/download-artifact@v8
19+
with:
20+
name: ${{ inputs.backend-artifact-name-prefix }}-macos-${{ inputs.architecture }}
21+
path: ${{ runner.temp }}/backend
22+
23+
- name: Download linux-amd64 packaged files
24+
uses: actions/download-artifact@v8
25+
with:
26+
name: ${{ inputs.package-file-name-prefix }}-linux-amd64.tar.gz
27+
path: ${{ runner.temp }}/package
28+
29+
- name: Extract frontend files from linux-amd64 package
30+
shell: bash
31+
run: |
32+
mkdir -p package
33+
tar -xzf ${{ runner.temp }}/package/${{ inputs.package-file-name-prefix }}-linux-amd64.tar.gz -C package
34+
35+
- name: Package macOS-${{ inputs.architecture }} package
36+
shell: bash
37+
run: |
38+
mkdir -p ezbookkeeping
39+
mkdir -p ezbookkeeping/data
40+
mkdir -p ezbookkeeping/storage
41+
mkdir -p ezbookkeeping/log
42+
cp ${{ runner.temp }}/backend/ezbookkeeping ezbookkeeping/
43+
cp -R package/public ezbookkeeping/public
44+
cp -R conf ezbookkeeping/conf
45+
cp -R templates ezbookkeeping/templates
46+
cp LICENSE ezbookkeeping/
47+
cd ezbookkeeping
48+
chmod +x ezbookkeeping
49+
tar -czf ${{ runner.temp }}/${{ inputs.package-file-name-prefix }}-macos-${{ inputs.architecture }}.tar.gz *
50+
cd ..
51+
rm -rf ezbookkeeping
52+
53+
- name: Upload macOS-${{ inputs.architecture }} artifact
54+
uses: actions/upload-artifact@v7
55+
with:
56+
archive: false
57+
path: ${{ runner.temp }}/${{ inputs.package-file-name-prefix }}-macos-${{ inputs.architecture }}.tar.gz
58+
if-no-files-found: error

.github/workflows/build-non-main-branch.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ jobs:
128128
skip-tests: ${{ vars.SKIP_TESTS }}
129129
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
130130

131+
build-macos-backend:
132+
needs:
133+
- setup
134+
runs-on: macos-latest
135+
steps:
136+
- name: Checkout
137+
uses: actions/checkout@v6
138+
139+
- uses: ./.github/actions/build-macos-backend
140+
with:
141+
architecture: arm64
142+
build-unix-time: ${{ needs.setup.outputs.build-unix-time }}
143+
build-date: ${{ needs.setup.outputs.build-date }}
144+
check-3rd-api: ${{ vars.CHECK_3RD_API }}
145+
skip-tests: ${{ vars.SKIP_TESTS }}
146+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
147+
131148
build-windows-package:
132149
needs:
133150
- setup
@@ -142,3 +159,19 @@ jobs:
142159
with:
143160
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
144161
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
162+
163+
build-macos-package:
164+
needs:
165+
- setup
166+
- build-macos-backend
167+
- build-linux-docker-and-package-x86
168+
runs-on: macos-latest
169+
steps:
170+
- name: Checkout
171+
uses: actions/checkout@v6
172+
173+
- uses: ./.github/actions/build-macos-package
174+
with:
175+
architecture: arm64
176+
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
177+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}

.github/workflows/build-release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,24 @@ jobs:
162162
skip-tests: ${{ vars.SKIP_TESTS }}
163163
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
164164

165+
build-macos-backend:
166+
needs:
167+
- setup
168+
runs-on: macos-latest
169+
steps:
170+
- name: Checkout
171+
uses: actions/checkout@v6
172+
173+
- uses: ./.github/actions/build-macos-backend
174+
with:
175+
architecture: arm64
176+
release-build: 1
177+
build-unix-time: ${{ needs.setup.outputs.build-unix-time }}
178+
build-date: ${{ needs.setup.outputs.build-date }}
179+
check-3rd-api: ${{ vars.CHECK_3RD_API }}
180+
skip-tests: ${{ vars.SKIP_TESTS }}
181+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
182+
165183
build-windows-package:
166184
needs:
167185
- setup
@@ -177,13 +195,30 @@ jobs:
177195
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
178196
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
179197

198+
build-macos-package:
199+
needs:
200+
- setup
201+
- build-macos-backend
202+
- build-linux-docker-and-package-x86
203+
runs-on: macos-latest
204+
steps:
205+
- name: Checkout
206+
uses: actions/checkout@v6
207+
208+
- uses: ./.github/actions/build-macos-package
209+
with:
210+
architecture: arm64
211+
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
212+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
213+
180214
publish-release:
181215
runs-on: ubuntu-latest
182216
needs:
183217
- setup
184218
- build-linux-docker-and-package-x86
185219
- build-linux-docker-and-package-arm
186220
- build-windows-package
221+
- build-macos-package
187222
- push-linux-docker
188223
steps:
189224
- name: Download all packaged files

.github/workflows/build-snapshot.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,23 @@ jobs:
159159
skip-tests: ${{ vars.SKIP_TESTS }}
160160
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
161161

162+
build-macos-backend:
163+
needs:
164+
- setup
165+
runs-on: macos-latest
166+
steps:
167+
- name: Checkout
168+
uses: actions/checkout@v6
169+
170+
- uses: ./.github/actions/build-macos-backend
171+
with:
172+
architecture: arm64
173+
build-unix-time: ${{ needs.setup.outputs.build-unix-time }}
174+
build-date: ${{ needs.setup.outputs.build-date }}
175+
check-3rd-api: ${{ vars.CHECK_3RD_API }}
176+
skip-tests: ${{ vars.SKIP_TESTS }}
177+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
178+
162179
build-windows-package:
163180
needs:
164181
- setup
@@ -173,3 +190,19 @@ jobs:
173190
with:
174191
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
175192
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}
193+
194+
build-macos-package:
195+
needs:
196+
- setup
197+
- build-macos-backend
198+
- build-linux-docker-and-package-x86
199+
runs-on: macos-latest
200+
steps:
201+
- name: Checkout
202+
uses: actions/checkout@v6
203+
204+
- uses: ./.github/actions/build-macos-package
205+
with:
206+
architecture: arm64
207+
package-file-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-package-file-name-prefix }}
208+
backend-artifact-name-prefix: ${{ needs.setup.outputs.ezbookkeeping-backend-artifact-name-prefix }}

build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ build_backend() {
160160
fi
161161
fi
162162

163+
ld_static_link_flags=""
164+
165+
if [ "$(uname -s)" = "Linux" ]; then
166+
ld_static_link_flags="-linkmode external -extldflags '-static'"
167+
fi
168+
163169
backend_build_extra_arguments="-X main.Version=$VERSION"
164170
backend_build_extra_arguments="$backend_build_extra_arguments -X main.CommitHash=$COMMIT_HASH"
165171

@@ -169,7 +175,7 @@ build_backend() {
169175

170176
echo "Building backend binary file ($RELEASE_TYPE)..."
171177

172-
CGO_ENABLED=1 go build -a -v -trimpath -ldflags "-w -s -linkmode external -extldflags '-static' $backend_build_extra_arguments" -o ezbookkeeping ezbookkeeping.go
178+
CGO_ENABLED=1 go build -a -v -trimpath -ldflags "-w -s $ld_static_link_flags $backend_build_extra_arguments" -o ezbookkeeping ezbookkeeping.go
173179
chmod +x ezbookkeeping
174180
}
175181

0 commit comments

Comments
 (0)