-
Notifications
You must be signed in to change notification settings - Fork 63
137 lines (126 loc) · 4.17 KB
/
compile.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
name: Compile and Upload Binaries
on:
release:
types: [published]
push:
tags-ignore:
# ignore all pushed tags
- '**'
branches:
# run for all branches
- '**'
jobs:
assemble-os-matrix:
runs-on: ubuntu-22.04
name: Assemble Matrix
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Create Matrix
id: set-matrix
run: ./ci/target-matrix.sh >> "$GITHUB_OUTPUT"
go-build:
needs: [ assemble-os-matrix ]
name: Go Build
strategy:
matrix: ${{ fromJson(needs.assemble-os-matrix.outputs.matrix) }}
runs-on: ${{ matrix.buildplatform }}
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
check-latest: true
cache-dependency-path: dbee/go.sum
- name: Setup Zig for C Cross Compilation
uses: goto-bus-stop/setup-zig@v2
- name: Build
id: build
working-directory: dbee
shell: bash
run: |
bin="dbee"
[ '${{ matrix.goos }}' = "windows" ] && bin="dbee.exe"
artefact="dbee_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
echo "artefact=$artefact" >> "$GITHUB_OUTPUT"
../ci/build.sh \
-o "${{ matrix.goos }}" \
-a "${{ matrix.goarch }}" \
-c "${{ matrix.crossarch }}" \
-b "${{ matrix.buildtags }}" \
-e "${{ matrix.cgo }}" \
-p "../ci_tmp/bin/$bin"
tar -C "../ci_tmp/bin" -czvf "../ci_tmp/bin/$artefact" "$bin"
- name: Upload artefacts to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
file: ci_tmp/bin/${{ steps.build.outputs.artefact }}
tag: ${{ github.ref }}
- name: Create metadata
if: github.event_name == 'release'
shell: bash
run: |
mkdir ci_tmp/meta
echo "${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.build.outputs.artefact }}" > ci_tmp/meta/url
echo "${{ matrix.goos }}" > ci_tmp/meta/os
echo "${{ matrix.goarch }}" > ci_tmp/meta/arch
- name: Upload metadata
if: github.event_name == 'release'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.goos }}_${{ matrix.goarch }}
path: ci_tmp/meta/*
create-install-manifest:
runs-on: ubuntu-22.04
if: github.event_name == 'release'
name: Create Install Manifest
needs: [ go-build ]
env:
MANIFEST_FILE: "lua/dbee/install/__manifest.lua"
steps:
- uses: actions/checkout@v3
- name: Get metadata
uses: actions/download-artifact@v3
with:
path: meta
- name: Create Install File from metadata
run: |
{
echo "-- This file is automatically generated using CI pipeline"
echo "-- DO NOT EDIT!"
echo "local M = {}"
echo
echo "-- Links to binary releases"
echo "M.urls = {"
for art in meta/*; do
os="$(cat "$art/os")"
arch="$(cat "$art/arch")"
url="$(cat "$art/url")"
echo " [\"$os/$arch\"] = \"$url\","
done
echo "}"
echo
echo "return M"
} > "$MANIFEST_FILE"
- name: Commit Generated Manifest
shell: bash
run: |
echo "fetching"
git fetch
branch=$(basename "$(git branch -r --contains="${{ github.ref }}" | head -n1 | cut -c3-)")
echo "checking out"
git pull origin "$branch" --rebase --autostash
git checkout "$branch"
echo "committing"
git add "${{ env.MANIFEST_FILE }}"
git config user.name "Github Actions"
git config user.email "actions@github.com"
git commit -m "[install] update install manifest"
echo "pushing"
git push -u origin "$branch"
echo "moving tag"
git tag -f "${{ github.ref_name }}"
git push origin -f --tags