-
Notifications
You must be signed in to change notification settings - Fork 23
181 lines (169 loc) · 4.91 KB
/
ccpp.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
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
name: C/C++ CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
bump-tag-dry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get next version
id: tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
DRY_RUN: true
- name: create tag file
run: |
echo ${{ steps.tag.outputs.new_tag }} > tag.txt
- name: upload new tag artifact
uses: actions/upload-artifact@v4
with:
name: uploads/tag.txt
path: tag.txt
build-linux:
runs-on: ubuntu-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: uploads
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build
run: |
npm install -g bats
export DUPLO_VERSION=`cat ./uploads/tag.txt`
mkdir -p build
pushd build
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
make
popd
zip --junk-paths duplo-linux build/duplo
- name: upload linux artifact
uses: actions/upload-artifact@v4
with:
name: uploads/duplo-linux.zip
path: duplo-linux.zip
build-macos:
runs-on: macos-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: uploads
- name: build
run: |
brew install bats-core
export DUPLO_VERSION=`cat ./uploads/tag.txt`
mkdir -p build
pushd build
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
make
popd
zip --junk-paths duplo-macos build/duplo
- name: upload macos artifact
uses: actions/upload-artifact@v4
with:
name: uploads/duplo-macos.zip
path: duplo-macos.zip
push-docker-image:
runs-on: ubuntu-latest
needs: [bump-tag-dry]
steps:
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: uploads
- name: set version
id: version
run: |
DUPLO_VERSION=$(cat ./uploads/tag.txt)
echo $DUPLO_VERSION
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_ENV
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
push: false
tags: "dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}"
build-args: |
"DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}"
- name: Docker build and push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
push: true
tags: "dlidstrom/duplo:latest,dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}"
build-args: |
"DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}"
upload-release:
if: success()
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
id: tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
- name: create release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: Release ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: uploads
- name: upload macos
id: upload-macos
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-macos.zip
asset_name: duplo-macos.zip
asset_content_type: application/zip
- name: upload linux
id: upload-linux
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-linux.zip
asset_name: duplo-linux.zip
asset_content_type: application/zip