This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (125 loc) · 4.47 KB
/
core-build-and-draft.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
136
137
138
139
140
141
name: Core - Build and Draft
on:
workflow_dispatch:
inputs:
version:
description: "Version to tag the release with, leave empty to not make a release"
required: false
type: string
workflow_call:
inputs:
version:
description: "Version to tag the release with, leave empty to not make a release"
required: false
type: string
env:
CARGO_TERM_COLOR: always
jobs:
core-build-and-draft:
strategy:
fail-fast: false
matrix:
include:
- platform: "windows-latest"
target: "x86_64-pc-windows-msvc"
os: "windows"
arch: "x86_64"
postfix: ".exe"
cross: false
- platform: "ubuntu-latest"
target: "x86_64-unknown-linux-gnu"
os: "linux"
arch: "x86_64"
postfix: ""
cross: false
- platform: "self-hosted"
target: "aarch64-unknown-linux-gnu"
os: "linux"
arch: "aarch64"
postfix: ""
cross: false
- platform: "macos-latest"
target: "x86_64-apple-darwin"
os: "macos"
arch: "x86_64"
postfix: ""
cross: false
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: rust-cache
shared-key: ${{ matrix.target }}-release-build
key: workspace
- name: Find Version (Linux, MacOS)
id: find_version
if: runner.os != 'Windows'
run: |
VERSION="v$(grep "^version" Cargo.toml | cut -d = -f 2 | sed -E "s/\"//g" | sed -E "s/ //g")"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
FILENAME="lodestone_core_${{matrix.os}}_${{matrix.arch}}_${VERSION}${{matrix.postfix}}"
echo "FILENAME=${FILENAME}" >> $GITHUB_ENV
- name: Find Version (Windows)
id: find_version_windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$VERSION = "v" + (Get-Content Cargo.toml | Select-String -Pattern "^version" | ForEach-Object { $_.ToString().Split("=")[1].Trim().Replace("`"", "") })
echo "VERSION=$VERSION" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
$FILENAME = "lodestone_core_${{matrix.os}}_${{matrix.arch}}_$VERSION${{matrix.postfix}}"
echo "FILENAME=$FILENAME" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
# - name: Verify Version
# if: inputs.version && false
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# if (process.env.VERSION != ${{ inputs.version }}) {
# core.setFailed("Version mismatch: " + process.env.VERSION + " != " + ${{ inputs.version }});
# }
- name: Build Lodestone Core
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --features "vendored-openssl" --target ${{ matrix.target }}
- name: Rename File (Linux, MacOS)
if: runner.os != 'Windows'
run: |
mv ./target/${{ matrix.target }}/release/main${{ matrix.postfix }} ./${{ env.FILENAME }}
- name: Rename File (Windows)
if: runner.os == 'Windows'
run: |
echo "::debug::$(ls)"
Move-Item -Path "./target/${{ matrix.target }}/release/main${{ matrix.postfix }}" -Destination "./${{ env.FILENAME }}"
# for debugging
echo "::debug::Listing files in current directory"
echo "::debug::$(ls)"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{env.FILENAME}}
path: ./${{env.FILENAME}}
- name: Draft Release
uses: softprops/action-gh-release@v1
if: inputs.version
with:
files: ./${{env.FILENAME}}
tag_name: ${{env.VERSION}}
draft: true
prerelease: true