-
Notifications
You must be signed in to change notification settings - Fork 10
222 lines (188 loc) · 6.78 KB
/
Copy pathbuild-and-release.yml
File metadata and controls
222 lines (188 loc) · 6.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Build and Release
on: push
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
include:
- os: ubuntu-latest
image: ubuntu:latest
- os: macos-latest
image: macos-latest
#- os: windows-latest
#image: windows-latest
steps:
- name: Set dummy ACTIONS_RUNTIME_TOKEN and ACTIONS_RUNTIME_URL for act
if: ${{ env.ACT }}
run: |
echo "ACTIONS_RUNTIME_TOKEN=dummy_token" >> $GITHUB_ENV
echo "ACTIONS_RUNTIME_URL=https://dummy_url" >> $GITHUB_ENV
# - name: Install GCC on Ubuntu
# if: matrix.os == 'ubuntu-latest' && ${{env.ACT}}
# run: |
# apt-get update
# apt-get install -y gcc
# - name: Install GCC on macOS
# if: matrix.os == 'macos-latest' && ${{ env.ACT }}
# run: |
# brew install gcc
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Build on Linux
if: matrix.os == 'ubuntu-latest'
run: |
cmake -B build/
cmake --build build/
mkdir -p ${{ matrix.os }}
cp build/await ${{ matrix.os }}/
cp build/await.fish ${{ matrix.os }}/
cp build/await.bash ${{ matrix.os }}/
cp build/await.zsh ${{ matrix.os }}/
# Copy binary to project root for tests
cp build/await ./await
- name: Build on macOS (arm64)
if: matrix.os == 'macos-latest'
run: |
cmake -B build-arm64/ -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build build-arm64/
mkdir -p macos-latest-arm64
cp build-arm64/await macos-latest-arm64/
cp build-arm64/await.fish macos-latest-arm64/
cp build-arm64/await.bash macos-latest-arm64/
cp build-arm64/await.zsh macos-latest-arm64/
- name: Build on macOS (x86_64)
if: matrix.os == 'macos-latest'
run: |
cmake -B build-x86_64/ -DCMAKE_OSX_ARCHITECTURES=x86_64
cmake --build build-x86_64/
mkdir -p macos-latest-x86_64
cp build-x86_64/await macos-latest-x86_64/
cp build-x86_64/await.fish macos-latest-x86_64/
cp build-x86_64/await.bash macos-latest-x86_64/
cp build-x86_64/await.zsh macos-latest-x86_64/
# Copy x86_64 binary to project root for tests on macOS
cp build-x86_64/await ./await
- name: Install test dependencies
working-directory: tests
run: |
pip install -e .
pip install pytest pytest-timeout
- name: Run tests
working-directory: tests
run: |
pytest test_await.py -v
- name: Tree
if: matrix.os == 'ubuntu-latest'
run: tree
- uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: await-${{ matrix.os }}
path: ${{ matrix.os }}
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: await-macos-latest-arm64
path: macos-latest-arm64
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: await-macos-latest-x86_64
path: macos-latest-x86_64
release:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history and tags for release notes generation
- name: Build await to get version
run: |
cmake -B build/
cmake --build build/
- name: Get version from await CLI
id: get_version
run: |
VERSION=$(./build/await --version)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Generate Release Notes
id: release_notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
# Get all tags sorted by version
PREV_TAG=$(git tag -l --sort=-v:refname | grep -v "^${VERSION}$" | head -n1)
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, using initial commit"
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "Generating release notes from $PREV_TAG to $VERSION"
# Generate release notes from commits
RELEASE_NOTES="## Release $VERSION"
RELEASE_NOTES="${RELEASE_NOTES}\n\n### Changes since ${PREV_TAG}\n"
# Get commit messages, excluding merge commits and version bumps
COMMITS=$(git log ${PREV_TAG}..HEAD --oneline --no-merges --pretty=format:"- %s" | grep -v "^- Bump version")
if [ -z "$COMMITS" ]; then
RELEASE_NOTES="${RELEASE_NOTES}\n- Minor updates and improvements"
else
RELEASE_NOTES="${RELEASE_NOTES}\n${COMMITS}"
fi
# Save to file for multi-line handling
echo -e "$RELEASE_NOTES" > release_notes.md
# Also output for logging
echo "Release notes:"
cat release_notes.md
- name: Check if Release Exists
id: check_release
run: |
gh release view ${{ steps.get_version.outputs.VERSION }} || echo "Release does not exist"
- name: Create or Update Release
id: create_update_release
if: steps.check_release.outputs.exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
body_path: release_notes.md
draft: false
prerelease: false
- name: Update Release Archives
if: steps.check_release.outputs.exists == 'true'
run: |
gh release upload ${{ steps.get_version.outputs.VERSION }} archives/* --clobber
- name: Download Artifact
uses: actions/download-artifact@v4
- name: Create Archives
run: |
mkdir -p archives
tree
cd await-macos-latest-arm64 && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-aarch64-apple-darwin.tar.gz * && cd ..
cd await-macos-latest-x86_64 && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin.tar.gz * && cd ..
cd await-ubuntu-latest && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu.tar.gz * && cd ..
tree
- name: Upload Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: archives/*
tag_name: ${{ steps.get_version.outputs.VERSION }}
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}