forked from seaofvoices/darklua
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (120 loc) · 3.9 KB
/
release.yml
File metadata and controls
143 lines (120 loc) · 3.9 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
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
136
137
138
139
140
141
142
143
name: Release
on:
workflow_dispatch:
inputs:
release_tag:
description: 'The version to release starting with `v`'
required: true
type: string
release_ref:
description: 'The branch, tag or SHA to checkout (default to latest)'
default: ''
type: string
permissions:
contents: write
jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- name: Create tag
run: |
git fetch --tags --no-recurse-submodules
if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then
git tag ${{ inputs.release_tag }}
git push origin ${{ inputs.release_tag }}
fi
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.release_tag }}
name: ${{ inputs.release_tag }}
draft: false
build:
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
artifact-name: darklua-windows-x86_64
cargo-target: x86_64-pc-windows-msvc
- os: ubuntu-latest
artifact-name: darklua-linux-x86_64
cargo-target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
artifact-name: darklua-linux-aarch64
cargo-target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
- os: macos-latest
artifact-name: darklua-macos-x86_64
cargo-target: x86_64-apple-darwin
- os: macos-latest
artifact-name: darklua-macos-aarch64
cargo-target: aarch64-apple-darwin
name: Build darklua (${{ matrix.artifact-name }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.release_ref }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.cargo-target }}
override: true
profile: minimal
- name: Install linker
if: ${{ matrix.linker != '' }}
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
if [ ! -f ".cargo/config.toml" ]; then
mkdir .cargo
echo "[target.aarch64-unknown-linux-gnu]" > .cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
fi
- name: Generate Cargo.lock if needed
shell: bash
run: |
if [ ! -f "Cargo.lock" ]; then
cargo generate-lockfile
fi
- name: Build darklua binary
run: cargo build --locked --release --target ${{ matrix.cargo-target }}
env:
CARGO_TARGET_DIR: output
- name: Setup archive
shell: bash
run: |
mkdir -p staging
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "output/${{ matrix.cargo-target }}/release/darklua.exe" staging/
cd staging
7z a ../release.zip *
else
cp "output/${{ matrix.cargo-target }}/release/darklua" staging/
cd staging
zip ../release.zip *
fi
- name: Upload archive
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: release.zip
- name: Upload Binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: release.zip
asset_name: ${{ matrix.artifact-name }}.zip
asset_content_type: application/zip