-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (148 loc) · 5.21 KB
/
rust.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: dreamluau
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
inputs:
force_rebuild:
description: "Force Rebuild"
required: false
type: "boolean"
release:
description: "Prepare Release"
type: "choice"
default: "No Release"
options:
- "No Release"
- "Dry Run"
- "Full Release"
jobs:
check-should-rebuild:
outputs:
should-rebuild: ${{ (inputs.release && inputs.release != 'No Release') || inputs.force_rebuild || steps.changed-files.outputs.any_changed }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
if: ${{ (inputs.release && inputs.release != 'No Release') && !inputs.force_rebuild }}
- name: Check Modified Files
uses: tj-actions/changed-files@v44
if: ${{ (inputs.release && inputs.release != 'No Release') && !inputs.force_rebuild }}
id: changed-files
with:
files: |
**/*.rs
Cargo.lock
build-windows:
runs-on: windows-latest
needs: check-should-rebuild
if: ${{ needs.check-should-rebuild.outputs.should-rebuild == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: i686-pc-windows-msvc
components: rustfmt, clippy
- name: Clippy (all features)
run: cargo clippy --target i686-pc-windows-msvc --locked -- -D warnings
- name: Rustfmt
run: cargo fmt -- --check
- name: Build (release) (default features)
run: cargo build --target i686-pc-windows-msvc --locked --release
- uses: actions/upload-artifact@v4
with:
name: dreamluau_windows
path: target/i686-pc-windows-msvc/release/dreamluau.dll
build-linux:
runs-on: ubuntu-20.04
needs: check-should-rebuild
if: ${{ needs.check-should-rebuild.outputs.should-rebuild == 'true' }}
env:
BYOND_MAJOR: 515
BYOND_MINOR: 1640
PKG_CONFIG_ALLOW_CROSS: 1
steps:
- uses: actions/checkout@v4
- run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install g++-multilib zlib1g-dev:i386 libssl-dev:i386
./scripts/install_byond.sh
- uses: dtolnay/rust-toolchain@stable
with:
targets: i686-unknown-linux-gnu
- name: Check (all features)
run: cargo check --target i686-unknown-linux-gnu --locked
- name: Build (Debug) (all features)
run: cargo build --target i686-unknown-linux-gnu --locked
- name: Run tests (all features)
run: cargo test --target i686-unknown-linux-gnu --locked
env:
BYOND_BIN: /home/runner/BYOND/byond/bin
- name: Build (release) (default features)
run: cargo build --target i686-unknown-linux-gnu --locked --release
- uses: actions/upload-artifact@v4
with:
name: dreamluau_linux
path: target/i686-unknown-linux-gnu/release/libdreamluau.so
release:
runs-on: ubuntu-20.04
needs: ["build-windows", "build-linux"]
if: ${{ inputs.release && inputs.release != 'No Release' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
if: ${{ inputs.release == 'Full Release' }}
id: download_artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get changelog
run: |
VERSION=`grep -Po '(?<=^version = ")([^"]+)' ./Cargo.toml`
echo "VERSION=$VERSION" >> $GITHUB_ENV
CHANGELOG_ENTRY=`grep --color=never -m 1 -Po '## \K(\[[0-9\.]+\].*)' CHANGELOG.md`
mkdir tmp
`bash ./scripts/extract_changelog.sh $CHANGELOG_ENTRY > ./tmp/CHANGELOG.md`
- name: Get Tags
id: tags
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/git/matching-refs/tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Tag is New
if: ${{ contains(steps.tags.outputs.data.*.ref, format('refs/tags/{0}', env.VERSION)) }}
run: |
if [[ $INPUT_release -eq 'Full Release']]
then
echo "::error::A release with the tag \"$VERSION\" already exists."
exit 1
else
echo "::warning:::A release with the tag \"$VERSION\" already exists."
fi
- name: Upload Changelog (Dry Run)
if: ${{ inputs.release == 'Dry Run' }}
uses: actions/upload-artifact@v4
with:
name: CHANGELOG.md
path: tmp/CHANGELOG.md
- name: Create Release
id: create_release
if: ${{ inputs.release == 'Full Release' }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
body_path: tmp/CHANGELOG.md
files: |
${{ steps.download_artifacts.outputs.download-path }}/dreamluau_linux/libdreamluau.so
${{ steps.download_artifacts.outputs.download-path }}/dreamluau_windows/dreamluau.dll
dmsrc/api.dm