-
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.09 KB
/
release.yaml
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
name: Release
run-name: ${{ inputs.reason }}
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
reason:
description: Dispatch reason
required: true
type: string
jobs:
create-release:
name: Create Release
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release-id: ${{ steps.create-release.outputs.result }}
steps:
- name: Create release
id: create-release
uses: actions/github-script@v7
with:
script: |
const tag = context.ref.split('/').at(-1);
const release = await github.rest.repos.createRelease({
name: `Release ${tag}`,
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
generate_release_notes: true
});
return release.data.id;
build-and-upload:
name: Build and Upload
needs: create-release
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup or update Rust toolchain
run: rustup toolchain install stable --profile default
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: stable
- name: Build project
run: cargo build --verbose --release
- name: Upload release asset
uses: actions/github-script@v7
with:
script: |
const asset = await (await import("node:fs/promises")).readFile(`target/release/${context.repo.repo}${{ runner.os == 'Windows' && '.exe' || '' }}`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-release.outputs.release-id }},
name: "lure-release-${{ runner.os }}",
data: asset
});