-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (123 loc) · 3.92 KB
/
Copy pathrelease.yml
File metadata and controls
136 lines (123 loc) · 3.92 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release tag to build, for example v0.1.0"
required: true
permissions:
contents: write
jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-musl
build_tool: cross
binary: diskd
- os: ubuntu-24.04
target: aarch64-unknown-linux-musl
build_tool: cross
binary: diskd
- os: macos-14
target: x86_64-apple-darwin
build_tool: cargo
binary: diskd
- os: macos-14
target: aarch64-apple-darwin
build_tool: cargo
binary: diskd
- os: windows-2022
target: x86_64-pc-windows-msvc
build_tool: cargo
binary: diskd.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve version
shell: bash
run: |
set -euo pipefail
if [ -n "${{ github.event.inputs.version || '' }}" ]; then
echo "DISKD_VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_ENV"
else
echo "DISKD_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
fi
- name: Install Rust target
shell: bash
run: |
set -euo pipefail
rustup target add "${{ matrix.target }}"
- name: Install cross
if: matrix.build_tool == 'cross'
shell: bash
run: |
set -euo pipefail
cargo install cross --version =0.2.5 --locked
- name: Build
shell: bash
run: |
set -euo pipefail
if [ "${{ matrix.build_tool }}" = "cross" ]; then
cross build --release --target "${{ matrix.target }}" -p diskd-cli
else
cargo build --release --target "${{ matrix.target }}" -p diskd-cli
fi
- name: Package
shell: bash
run: |
set -euo pipefail
stem="diskd-${DISKD_VERSION}-${{ matrix.target }}"
archive="${stem}.tar.gz"
mkdir -p "dist/${stem}"
cp "target/${{ matrix.target }}/release/${{ matrix.binary }}" "dist/${stem}/diskd"
chmod 0755 "dist/${stem}/diskd"
tar -czf "dist/${archive}" -C "dist/${stem}" diskd
if command -v shasum >/dev/null 2>&1; then
(cd dist && shasum -a 256 "${archive}" > "${archive}.sha256")
else
(cd dist && sha256sum "${archive}" > "${archive}.sha256")
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: diskd-${{ matrix.target }}
path: |
dist/*.tar.gz
dist/*.sha256
publish:
name: publish GitHub release
needs: build
runs-on: ubuntu-24.04
steps:
- name: Resolve version
shell: bash
run: |
set -euo pipefail
if [ -n "${{ github.event.inputs.version || '' }}" ]; then
echo "DISKD_VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_ENV"
else
echo "DISKD_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
fi
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
if ! gh release view "$DISKD_VERSION" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$DISKD_VERSION" --repo "$GITHUB_REPOSITORY" --title "$DISKD_VERSION" --notes "diskd CLI $DISKD_VERSION"
fi
gh release upload "$DISKD_VERSION" dist/*.tar.gz dist/*.sha256 --repo "$GITHUB_REPOSITORY" --clobber