-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (137 loc) · 5.05 KB
/
Copy pathcli-build.yml
File metadata and controls
155 lines (137 loc) · 5.05 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
name: Build CLI binaries
on:
pull_request:
paths:
- "cli/**"
- ".github/workflows/cli-build.yml"
push:
branches:
- dev
- prod
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: ${{ matrix.artifact_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.11"
artifact_name: stacksync-linux-x64
binary_name: stacksync
artifact_path: cli/dist/stacksync-linux-x64
- os: ubuntu-24.04-arm
python-version: "3.11"
artifact_name: stacksync-linux-arm64
binary_name: stacksync
artifact_path: cli/dist/stacksync-linux-arm64
- os: macos-latest
python-version: "3.11"
artifact_name: stacksync-macos-arm64
binary_name: stacksync
artifact_path: cli/dist/stacksync-macos-arm64
- os: windows-latest
python-version: "3.11"
artifact_name: stacksync-windows-x64.exe
binary_name: stacksync.exe
artifact_path: cli/dist/stacksync-windows-x64.exe
defaults:
run:
working-directory: cli
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Create virtual environment
shell: bash
run: python -m venv .venv
- name: Build standalone binary
if: runner.os != 'Windows'
shell: bash
run: |
source .venv/bin/activate
./scripts/build-binary.sh
- name: Build standalone binary
if: runner.os == 'Windows'
shell: pwsh
run: |
.\.venv\Scripts\python -m pip install -U pip
.\.venv\Scripts\python -m pip install -e .
.\.venv\Scripts\python -m pip install -r requirements-dev.txt
.\.venv\Scripts\python -m PyInstaller --clean --noconfirm stacksync.spec
- name: Rename release artifact
if: runner.os != 'Windows'
shell: bash
run: cp "dist/${{ matrix.binary_name }}" "dist/${{ matrix.artifact_name }}"
- name: Rename release artifact
if: runner.os == 'Windows'
shell: pwsh
run: Copy-Item "dist\${{ matrix.binary_name }}" "dist\${{ matrix.artifact_name }}"
- name: Smoke test binary
if: runner.os != 'Windows'
shell: bash
run: "./dist/${{ matrix.artifact_name }} --help"
- name: Smoke test binary
if: runner.os == 'Windows'
shell: pwsh
run: .\dist\${{ matrix.artifact_name }} --help
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
if-no-files-found: error
release:
name: Publish GitHub release
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/prod' || startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
- name: Compute release metadata
id: release_meta
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then
echo "tag_name=dev" >> "${GITHUB_OUTPUT}"
echo "release_name=Dev CLI Build" >> "${GITHUB_OUTPUT}"
echo "prerelease=true" >> "${GITHUB_OUTPUT}"
echo "make_latest=false" >> "${GITHUB_OUTPUT}"
elif [[ "${GITHUB_REF}" == "refs/heads/prod" ]]; then
echo "tag_name=prod" >> "${GITHUB_OUTPUT}"
echo "release_name=Prod CLI Build" >> "${GITHUB_OUTPUT}"
echo "prerelease=false" >> "${GITHUB_OUTPUT}"
echo "make_latest=true" >> "${GITHUB_OUTPUT}"
else
echo "tag_name=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
echo "release_name=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
echo "prerelease=false" >> "${GITHUB_OUTPUT}"
echo "make_latest=true" >> "${GITHUB_OUTPUT}"
fi
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_meta.outputs.tag_name }}
name: ${{ steps.release_meta.outputs.release_name }}
target_commitish: ${{ github.sha }}
prerelease: ${{ steps.release_meta.outputs.prerelease }}
make_latest: ${{ steps.release_meta.outputs.make_latest }}
overwrite_files: true
generate_release_notes: ${{ !startsWith(github.ref, 'refs/heads/') }}
files: |
release-assets/stacksync-linux-x64/stacksync-linux-x64
release-assets/stacksync-linux-arm64/stacksync-linux-arm64
release-assets/stacksync-macos-arm64/stacksync-macos-arm64
release-assets/stacksync-windows-x64.exe/stacksync-windows-x64.exe