-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (108 loc) · 3.92 KB
/
build.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
name: build
on:
push
workflow_dispatch
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
short_hash: ${{ steps.commit.outputs.short_hash }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Calculate short hash of commit
id: commit
run: echo "short_hash=$(echo $GITHUB_SHA | head -c 7)" >> "$GITHUB_OUTPUT"
- name: Cache project source
id: cache-project-source
uses: actions/cache@v4
with:
restore-keys: source-
key: source-${{ steps.commit.outputs.short_hash }}
path: |
.
!.git
- name: Checkout latest project source
uses: actions/checkout@v4
with:
submodules: recursive
- name: Calculate project release version
id: project
run: |
name="${GITHUB_REPOSITORY#*/}"
version="$(sed -n "s/^project($name VERSION \([0-9.]*\)).*/\1/p" CMakeLists.txt)"
echo "release=$version-rc+${{ steps.commit.outputs.short_hash }}" >> "$GITHUB_OUTPUT"
- name: Create release
id: create_release
continue-on-error: true
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.project.outputs.release }}
release_name: ${{ steps.project.outputs.release }}
draft: false
prerelease: true
build:
needs:
- prepare
runs-on: ubuntu-latest
strategy:
matrix:
target:
- windows
- linux
- macosx
steps:
- name: Restore project source from cache
uses: actions/cache/restore@v4
with:
key: source-${{ needs.prepare.outputs.short_hash }}
path: |
.
!.git
- name: Build cache
uses: actions/cache@v4
with:
restore-keys: build-
key: build-${{ needs.prepare.outputs.short_hash }}
path: build
- name: Setup contained image store
run: |
cat /etc/docker/daemon.json | jq '. | .+{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json
cat /etc/docker/daemon.json
sudo systemctl restart docker
docker info -f '{{ .DriverStatus }}'
docker info
- name: Build ${{ matrix.target }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make build-${{ matrix.target }}
- name: Find artifacts
run: |
echo "archive_asset_path=$(find target -name *.zip -o -name *.tar.gz)" >> "$GITHUB_ENV"
echo "sha256_asset_path=$(find target -name *.sha256)" >> "$GITHUB_ENV"
- name: Get artifact basenames and content types
run: |
echo "archive_asset_name=$(basename ${{ env.archive_asset_path }})" >> "$GITHUB_ENV"
echo "archive_asset_content_type=$(file --mime-type -b ${{ env.archive_asset_path }})" >> "$GITHUB_ENV"
echo "sha256_asset_name=$(basename ${{ env.sha256_asset_path }})" >> "$GITHUB_ENV"
echo "sha256_asset_content_type=$(file --mime-type -b ${{ env.sha256_asset_path }})" >> "$GITHUB_ENV"
- name: Upload archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare.outputs.upload_url }}
asset_path: ${{ env.archive_asset_path }}
asset_name: ${{ env.archive_asset_name }}
asset_content_type: ${{ env.archive_asset_content_type }}
- name: Upload sha256
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare.outputs.upload_url }}
asset_path: ${{ env.sha256_asset_path }}
asset_name: ${{ env.sha256_asset_name }}
asset_content_type: ${{ env.sha256_asset_content_type }}