-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (62 loc) · 2.15 KB
/
Copy pathrelease.yml
File metadata and controls
73 lines (62 loc) · 2.15 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to (re)build, e.g. v0.2.0"
required: true
permissions:
contents: write # required to create / upload to GitHub Releases
jobs:
build-linux-x86_64:
runs-on: ubuntu-latest
env:
TARGET: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Resolve tag
id: tag
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Verify tag matches Cargo.toml version
run: |
CARGO_VERSION=$(awk -F\" '/^version[[:space:]]*=/{print $2; exit}' Cargo.toml)
if [ "$CARGO_VERSION" != "${{ steps.tag.outputs.version }}" ]; then
echo "tag ${{ steps.tag.outputs.tag }} does not match Cargo.toml version $CARGO_VERSION" >&2
exit 1
fi
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev pkg-config
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET }}
- name: Build release binary
run: cargo build --release --bin otter --target ${{ env.TARGET }}
- name: Stage release binary
id: package
run: |
mkdir -p dist
ASSET="otter-${{ steps.tag.outputs.tag }}-${{ env.TARGET }}"
cp target/${{ env.TARGET }}/release/otter "dist/$ASSET"
chmod +x "dist/$ASSET"
(cd dist && shasum -a 256 "$ASSET" > "$ASSET.sha256")
echo "asset=$ASSET" >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}
generate_release_notes: true
files: |
dist/${{ steps.package.outputs.asset }}
dist/${{ steps.package.outputs.asset }}.sha256