-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.05 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
name: Build and Release
on:
push:
branches: [ master, bug/ci-windows-attestation ]
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
defaults:
run:
shell: bash
jobs:
create_release:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.create_release.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
- id: create_release
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "release_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
gh release create --generate-notes "${GITHUB_REF#refs/tags/}"
else
echo "release_tag=nightly" >> $GITHUB_OUTPUT
gh release delete --cleanup-tag --yes nightly
gh release create --generate-notes --prerelease --title "Development Build" nightly
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ env.GITHUB_REPOSITORY }}
build_assets:
permissions:
id-token: write
contents: write
attestations: write
needs: create_release
strategy:
matrix:
include:
# - target: x86_64-unknown-linux-gnu
# os: ubuntu-latest
# name: xsnippet-api-x86_64-linux.gz
# - target: aarch64-unknown-linux-gnu
# os: ubuntu-latest
# name: xsnippet-api-aarch64-linux.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: xsnippet-api-x86_64-windows.exe.7z
# - target: aarch64-apple-darwin
# os: macos-latest
# name: xsnippet-api-aarch64-macos.gz
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Setup PostgreSQL
uses: ikalnytskyi/action-setup-postgres@v6
- id: build
run: |
export HOST=$(rustc -vV | grep host: | awk '{print $2}')
if [ "$HOST" = "$TARGET" ]; then
cargo build --release --target ${TARGET}
else
cargo install cross
cross build --release --target ${TARGET}
fi
pushd target/${TARGET}/release
if [[ "$TARGET" =~ "windows" ]]; then
7z a $ASSET_NAME xsnippet-api.exe
else
tar cvzf $ASSET_NAME xsnippet-api
fi
gh release upload $RELEASE_TAG $ASSET_NAME
echo "asset_path=$PWD/$ASSET_NAME" >> $GITHUB_OUTPUT
popd
env:
ASSET_NAME: ${{ matrix.name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ env.GITHUB_REPOSITORY }}
TARGET: ${{ matrix.target }}
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }}
- uses: mxschmitt/action-tmate@v3
env:
ASSET_PATH: ${{ steps.build.outputs.asset_path }}
- uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ steps.build.outputs.asset_path }}