forked from hexops/mach-dxcompiler
-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (154 loc) · 6.52 KB
/
ci.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
name: CI
on:
push:
branches:
- 'main'
jobs:
draft_release:
if: ${{ !contains(github.event.head_commit.message, 'update to latest binary release') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create draft
run: |
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
gh release create "$RELEASE" --draft --title "$RELEASE"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create draft
run: |
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
gh release edit "$RELEASE" --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
all:
needs: draft_release
strategy:
matrix:
target: [
'x86_64-linux-gnu',
'x86_64-linux-musl',
'aarch64-linux-gnu',
'aarch64-linux-musl',
'x86_64-windows-gnu',
'aarch64-windows-gnu',
'x86_64-macos-none',
'aarch64-macos-none',
]
optimize: [Debug, ReleaseFast]
include:
- target: 'x86_64-linux-gnu'
cpu: '-Dcpu=x86_64_v2'
- target: 'x86_64-linux-musl'
cpu: '-Dcpu=x86_64_v2'
- target: 'x86_64-windows-gnu'
cpu: '-Dcpu=x86_64_v2'
- target: 'x86_64-macos-none'
cpu: '-Dcpu=x86_64_v2'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Zig
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.14.0-dev.1710+8ee52f99c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: build
run: zig build -Dfrom_source -Dtarget=${{ matrix.target }} -Doptimize=${{ matrix.optimize }} ${{ matrix.cpu }} install dxc
- name: upload
run: |
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_lib.tar.zst" -C zig-out/lib .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_bin.tar.zst" -C zig-out/bin .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_lib.tar.gz" -C zig-out/lib .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_bin.tar.gz" -C zig-out/bin .
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
gh release upload "$RELEASE" "${TARGET_OPT}_lib.tar.zst"
gh release upload "$RELEASE" "${TARGET_OPT}_bin.tar.zst"
gh release upload "$RELEASE" "${TARGET_OPT}_lib.tar.gz"
gh release upload "$RELEASE" "${TARGET_OPT}_bin.tar.gz"
env:
TARGET_OPT: ${{ matrix.target }}_${{ matrix.optimize }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
msvc:
# TODO: re-enable required MSVC builds
continue-on-error: true
needs: draft_release
strategy:
matrix:
target: [
'x86_64-windows-msvc',
# TODO: 'machine type x64 conflicts with arm64' during linking (zig bug)
# 'aarch64-windows-msvc',
]
optimize: [Debug, ReleaseFast]
include:
- target: 'x86_64-windows-msvc'
cpu: '-Dcpu=x86_64_v2'
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Zig
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.14.0-dev.1710+8ee52f99c.zip" -OutFile "C:\zig.zip"
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0-dev.1710+8ee52f99c\"
- name: build
run: zig build -Dfrom_source -Dtarget=${{ matrix.target }} -Doptimize=${{ matrix.optimize }} ${{ matrix.cpu }} install dxc
- name: upload
run: |
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_lib.tar.zst" -C zig-out/lib .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_bin.tar.zst" -C zig-out/bin .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_lib.tar.gz" -C zig-out/lib .
ZSTD_CLEVEL=19 tar -acf "${TARGET_OPT}_bin.tar.gz" -C zig-out/bin .
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
gh release upload "$RELEASE" "${TARGET_OPT}_lib.tar.zst"
gh release upload "$RELEASE" "${TARGET_OPT}_bin.tar.zst"
gh release upload "$RELEASE" "${TARGET_OPT}_lib.tar.gz"
gh release upload "$RELEASE" "${TARGET_OPT}_bin.tar.gz"
shell: bash
env:
WINDOWS: true
TARGET_OPT: ${{ matrix.target }}_${{ matrix.optimize }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
# TODO: re-enable required MSVC builds
# needs: [all, msvc]
needs: [all]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish release
run: |
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
gh release edit "$RELEASE" --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Record latest release version
id: recorded_release_version
# Note: we find the latest non-'update to latest binary release' commit here, which is not
# necessarily HEAD because another build could have succeeded before us and HEAD may now refer
# to 'update to latest binary release' instead of the commit we were building.
# By doing this, we ensure any update we push would refer to the absolute latest binary
# release even if *this* CI run is older.
run: echo "recorded_release_version=$(git log --oneline | grep -v 'update to latest binary release' | head -n1 | cut -d " " -f1)" >> $GITHUB_ENV
- name: Checkout hexops/mach-dxcompiler repo
uses: actions/checkout@v3
with:
repository: hexops/mach-dxcompiler
token: ${{ secrets.HEXOPS_MACH_DXCOMPILER_PUSH }}
- name: 'update hard-coded binary release version'
env:
RELEASE_COMMIT: ${{env.recorded_release_version}}
run: |
export RELEASE="$(date -u +%Y.%m.%d)+$(git rev-parse --short HEAD).${{ github.run_attempt }}"
sed -i "/const latest_binary_release =/c\const latest_binary_release = \"$RELEASE\";" ./build.zig
git config user.name 'Release automation'
git config user.email '[email protected]'
git add .
git commit -m 'update to latest binary release'
git push -u origin HEAD