Repository navigation
153 lines (130 loc) · 4.43 KB
/
Copy pathrelease-github.yml
File metadata and controls
153 lines (130 loc) · 4.43 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: GitHub Release
on:
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v0.2.0)"
required: true
# One release per tag at a time, and never cancelled: a half-built release
# has to finish or fail on its own. A second dispatch for the same tag waits.
concurrency:
group: release-github-${{ github.event.inputs.tag || github.ref }}
cancel-in-progress: false
permissions:
contents: write
env:
PROJECT_NAME: asc
CARGO_TERM_COLOR: always
jobs:
build:
name: Build binary (${{ matrix.name }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- name: win-amd64
runner: windows-latest
target: x86_64-pc-windows-msvc
- name: win-arm64
runner: windows-latest
target: aarch64-pc-windows-msvc
- name: macos-amd64
runner: macos-15-intel
target: x86_64-apple-darwin
- name: macos-arm64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Set the release version
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
release_version="${GITHUB_REF_NAME#v}"
else
release_version="${{ github.event.inputs.tag }}"
release_version="${release_version#v}"
fi
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
- name: Install toolkit
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: github-${{ matrix.target }}
- name: Build binary
shell: bash
run: cargo build --locked --release --target ${{ matrix.target }} --package smbcloud-ascapi-cli
- name: Package binary
shell: bash
run: |
BIN_SUFFIX=""
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_SUFFIX=".exe"
fi
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"
BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}"
mkdir -p ./release
mv "${BIN_OUTPUT}" "./release/${BIN_RELEASE}"
# Windows runners use bash from Git for Windows, which has sha256sum;
# macOS only has shasum.
- name: Checksum release assets
shell: bash
run: |
cd release
for asset in *; do
case "${asset}" in *.sha256) continue ;; esac
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "${asset}" | awk '{print $1}' > "${asset}.sha256"
else
shasum -a 256 "${asset}" | awk '{print $1}' > "${asset}.sha256"
fi
echo "${asset}: $(cat "${asset}.sha256")"
done
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.name }}
path: release/*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
steps:
- name: Resolve tag
id: tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
fi
- name: Download binary artifacts
uses: actions/download-artifact@v7
with:
pattern: "binary-*"
path: release
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: release/*
# Build the notes from the PRs since the previous tag, the same
# format as the "Generate release notes" button on the web UI.
generate_release_notes: true