-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (106 loc) · 3.53 KB
/
Copy pathrelease.yml
File metadata and controls
118 lines (106 loc) · 3.53 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
name: release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.2.0)"
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: build-${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
archive_ext: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
archive_ext: tar.gz
steps:
- uses: actions/checkout@v4
- name: Install musl tooling
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
if [[ "${{ matrix.target }}" == aarch64-* ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
fi
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.93
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Configure cross-linker for aarch64
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
mkdir -p .cargo
{
echo '[target.aarch64-unknown-linux-musl]'
echo 'linker = "aarch64-linux-gnu-gcc"'
} >> .cargo/config.toml
- name: Build release binaries
run: |
cargo build --release --target ${{ matrix.target }} \
--bin cortex-cli --bin cortex-daemon
- name: Package archive
id: package
env:
REF_NAME: ${{ github.ref_name }}
INPUT_TAG: ${{ github.event.inputs.tag }}
TARGET: ${{ matrix.target }}
run: |
# REF_NAME is set by GitHub on tag pushes; for workflow_dispatch we
# fall back to the user-supplied INPUT_TAG. Both are quoted via env
# to avoid command injection per github.com/security advisories.
VERSION="${REF_NAME#v}"
if [[ -z "$VERSION" || "$VERSION" == "$REF_NAME" ]]; then
VERSION="${INPUT_TAG#v}"
fi
STAGE="cortex-${VERSION}-${TARGET}"
mkdir -p "dist/$STAGE"
cp "target/${TARGET}/release/cortex-cli" "dist/$STAGE/cortex"
cp "target/${TARGET}/release/cortex-daemon" "dist/$STAGE/cortex-daemon"
[[ -f LICENSE ]] && cp LICENSE "dist/$STAGE/"
cp README.md "dist/$STAGE/"
tar -C dist -czf "dist/${STAGE}.tar.gz" "$STAGE"
(cd dist && sha256sum "${STAGE}.tar.gz" > "${STAGE}.tar.gz.sha256")
echo "archive=dist/${STAGE}.tar.gz" >> "$GITHUB_OUTPUT"
echo "sha256=dist/${STAGE}.tar.gz.sha256" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: cortex-${{ matrix.target }}
path: |
${{ steps.package.outputs.archive }}
${{ steps.package.outputs.sha256 }}
publish:
name: publish release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts to root
run: |
mkdir -p release
find artifacts -type f \( -name '*.tar.gz' -o -name '*.sha256' \) -exec cp {} release/ \;
ls -la release/
- uses: softprops/action-gh-release@v2
with:
files: release/*
draft: false
generate_release_notes: true