-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (103 loc) · 3.88 KB
/
release.yml
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
name: Create Release
on:
workflow_dispatch:
inputs:
draft:
required: false
default: true
description: Produce a draft release
type: boolean
jobs:
get-tags:
name: Create tagged release
runs-on: ubuntu-latest
outputs:
crate-version: ${{ steps.crate-version.outputs.CRATE_VERSION }}
old-version: ${{ steps.old-version.outputs.OLD_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Get old tag
id: old-version
shell: bash
run: |
echo OLD_VERSION="$(curl "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/tags" | jq -r '.[0].name')" >> $GITHUB_OUTPUT
- name: Get tag
id: crate-version
shell: bash
run: |
echo CRATE_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT
- run: "echo '::notice:: Tag = v${{ steps.crate-version.outputs.CRATE_VERSION }}'"
- name: Create draft release
if: ${{ github.event.inputs.draft }}
run: >
envsubst '$CRATE_VERSION $OLD_VERSION' < .github/release-notes.md |
gh release create "v$CRATE_VERSION" --title "v$CRATE_VERSION" --notes-file - --draft
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CRATE_VERSION: ${{ steps.crate-version.outputs.CRATE_VERSION }}
OLD_VERSION: ${{ steps.old-version.outputs.OLD_VERSION }}
- name: Create release
if: ${{ !github.event.inputs.draft }}
run: >
envsubst '$CRATE_VERSION $OLD_VERSION' < .github/release-notes.md |
gh release create "v$CRATE_VERSION" --notes-file -
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CRATE_VERSION: ${{ steps.crate-version.outputs.CRATE_VERSION }}
OLD_VERSION: ${{ steps.old-version.outputs.OLD_VERSION }}
build:
name: Build & Upload
runs-on: ${{ matrix.os }}
needs:
- get-tags
strategy:
fail-fast: false
matrix:
build:
- x86_64-linux
- x86_64-linux-musl
- x86_64-windows
feature:
- data-center
- cloud
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
build: x86_64-linux
ext: ""
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
build: x86_64-linux-musl
ext: ""
- target: x86_64-pc-windows-msvc
os: windows-latest
build: x86_64-windows
ext: .exe
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-release-${{ matrix.build }}-${{ matrix.feature }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: cargo-release-${{ matrix.build }}-${{ matrix.feature }}-
- if: ${{ contains(matrix.target, '-musl')}}
run: sudo apt install musl-tools
- uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: "Build ${{ matrix.build }} features: ${{ matrix.feature }}"
run: cargo +nightly build --release --features ${{ matrix.feature }} --target ${{ matrix.target }}
env:
RUSTFLAGS: -Zlocation-detail=none
- run: mkdir dist
- run: mv target/${{ matrix.target }}/release/jig${{ matrix.ext }} dist/jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}
- run: gh release upload 'v${{ needs.get-tags.outputs.crate-version }}' dist/jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: "echo '::notice:: Upload finished: jig-${{ matrix.feature }}-${{ matrix.target }}${{ matrix.ext }}'"