-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (112 loc) · 3.76 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (112 loc) · 3.76 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to build (e.g. v0.1.4)"
required: true
type: string
permissions:
contents: write
jobs:
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.runs_on }}
strategy:
fail-fast: false
matrix:
include:
- runs_on: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive_ext: tar.gz
binary_name: assemblyai-cli
- runs_on: windows-latest
target: x86_64-pc-windows-msvc
archive_ext: zip
binary_name: assemblyai-cli.exe
- runs_on: macos-14
target: x86_64-apple-darwin
archive_ext: tar.gz
binary_name: assemblyai-cli
- runs_on: macos-14
target: aarch64-apple-darwin
archive_ext: tar.gz
binary_name: assemblyai-cli
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
- name: Resolve tag
shell: bash
run: |
TAG="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Build
shell: bash
run: |
LOCKED_ARG=""
if [[ -f Cargo.lock ]]; then
LOCKED_ARG="--locked"
fi
cargo build --release $LOCKED_ARG --target "${{ matrix.target }}"
- name: Package (unix)
if: runner.os != 'Windows'
shell: bash
run: |
VERSION="${TAG#v}"
ARTIFACT_NAME="assemblyai-cli-${VERSION}-${{ matrix.target }}"
mkdir -p dist
BIN_PATH="target/${{ matrix.target }}/release/${{ matrix.binary_name }}"
chmod +x "$BIN_PATH"
tar -C "target/${{ matrix.target }}/release" -czf "dist/${ARTIFACT_NAME}.tar.gz" "${{ matrix.binary_name }}"
shasum -a 256 "dist/${ARTIFACT_NAME}.tar.gz" > "dist/${ARTIFACT_NAME}.tar.gz.sha256"
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$version = $env:TAG -replace '^v',''
$artifactName = "assemblyai-cli-$version-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path dist | Out-Null
$binPath = "target\\${{ matrix.target }}\\release\\${{ matrix.binary_name }}"
$zipPath = "dist\\$artifactName.zip"
Compress-Archive -Path $binPath -DestinationPath $zipPath -Force
$hash = (Get-FileHash -Path $zipPath -Algorithm SHA256).Hash.ToLower()
"$hash $artifactName.zip" | Out-File -FilePath "dist\\$artifactName.zip.sha256" -Encoding ascii
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: dist/*
release:
name: release
runs-on: ubuntu-latest
needs: build
steps:
- name: Resolve tag
shell: bash
run: |
TAG="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG }}
generate_release_notes: true
files: |
dist/**/*.tar.gz
dist/**/*.zip
dist/**/*.sha256