-
-
Notifications
You must be signed in to change notification settings - Fork 5
135 lines (114 loc) · 3.86 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "lsp version"
required: true
jobs:
check:
name: check
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: ./.github/actions/install-rust
- name: check
uses: ./.github/actions/check
compile:
name: compile ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
needs: check
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
archive: tar.gz
bootstrap: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
- target: x86_64-apple-darwin
runner: macos-latest
archive: tar.gz
bootstrap: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install openssl@3
echo "OPENSSL_DIR=$(/usr/local/bin/brew --prefix openssl@3)" >> $GITHUB_ENV
- target: aarch64-apple-darwin
runner: macos-latest
archive: tar.gz
bootstrap: echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
- target: x86_64-pc-windows-msvc
runner: windows-latest
archive: zip
steps:
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: ./.github/actions/install-rust
with:
targets: "${{ matrix.target }}"
- name: bootstrap
if: ${{ matrix.bootstrap != '' }}
run: ${{ matrix.bootstrap }}
- name: build binary
run: cargo build -p discord-presence-lsp --verbose --locked --release --target ${{ matrix.target }}
- name: prepare for upload
shell: bash
id: vars
run: |
BIN_SUFFIX=""
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_SUFFIX=".exe"
fi
BIN_OUTPUT="target/${{ matrix.target }}/release/discord-presence-lsp${BIN_SUFFIX}"
ARCHIVE_NAME="discord-presence-lsp-${{ matrix.target }}"
mkdir tmp/
mkdir "tmp/${ARCHIVE_NAME}"
mv "${BIN_OUTPUT}" "tmp/${ARCHIVE_NAME}"
cp LICENSE "tmp/${ARCHIVE_NAME}"
cp lsp/README.md "tmp/${ARCHIVE_NAME}"
if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then
ARCHIVE_PATH="tmp/${ARCHIVE_NAME}.tar.gz"
tar -czvf "${ARCHIVE_PATH}" -C "tmp" "${ARCHIVE_NAME}"
else
ARCHIVE_PATH="tmp/${ARCHIVE_NAME}.zip"
cd tmp
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
7z a "../${ARCHIVE_PATH}" "${ARCHIVE_NAME}"
else
zip -r "../${ARCHIVE_PATH}" "/${ARCHIVE_NAME}"
fi
cd ..
fi
echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
echo "archive_path=${ARCHIVE_PATH}" >> $GITHUB_OUTPUT
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.vars.outputs.archive_name }}
path: |
${{ steps.vars.outputs.archive_path }}
release:
name: release
runs-on: ubuntu-latest
needs: compile
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create the release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
name: v${{ inputs.version }}
draft: true
files: |
artifacts/**/*