-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (103 loc) · 4.73 KB
/
release.yml
File metadata and controls
126 lines (103 loc) · 4.73 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
name: Release
on:
release:
types: [published, prereleased]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
PLUGIN_NAME: https_samp
jobs:
build-release:
runs-on: ubuntu-latest
# Needs write access to attach .so/.dll/.inc to the GitHub release
# and to amend the release body with the auto-generated notes.
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Verify Cargo.toml version matches release tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
CARGO_VERSION="$(grep -m1 '^version' Cargo.toml | sed 's/.*= *"\(.*\)"/\1/')"
echo "Release tag: ${GITHUB_REF_NAME} (version=${TAG_VERSION})"
echo "Cargo.toml: ${CARGO_VERSION}"
if [ "${TAG_VERSION}" != "${CARGO_VERSION}" ]; then
echo "::error::Release tag (${GITHUB_REF_NAME}) does not match Cargo.toml version (${CARGO_VERSION})."
echo "::error::Bump Cargo.toml to ${TAG_VERSION} (or retag) and try again."
exit 1
fi
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: i686-unknown-linux-gnu,i686-pc-windows-msvc
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib clang llvm
- name: Install cargo-xwin
run: cargo install cargo-xwin --locked
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cache/cargo-xwin
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Build Linux (i686, SA-MP + native OMP)
run: cargo build --release --target i686-unknown-linux-gnu
- name: Build Windows (i686 MSVC, SA-MP + native OMP)
run: cargo xwin build --xwin-arch x86 --release --target i686-pc-windows-msvc
- name: Stage release artifacts
run: |
mkdir -p dist
cp "target/i686-unknown-linux-gnu/release/lib${PLUGIN_NAME}.so" "dist/${PLUGIN_NAME}.so"
cp "target/i686-pc-windows-msvc/release/${PLUGIN_NAME}.dll" "dist/${PLUGIN_NAME}.dll"
cp "include/${PLUGIN_NAME}.inc" "dist/${PLUGIN_NAME}.inc"
- name: Generate release notes
run: |
SDK_VERSION="$(grep -oP 'tag\s*=\s*"\Kv[0-9][^"]*' Cargo.toml | head -n1)"
PLUGIN_VERSION="$(grep -m1 '^version' Cargo.toml | sed 's/.*= *"\(.*\)"/\1/')"
# Extract the section for the current version from CHANGELOG.md.
# Format: "## [X.Y.Z] — yyyy/mm/dd" up to the next "## " heading.
CHANGELOG_SECTION=""
if [ -f CHANGELOG.md ]; then
CHANGELOG_SECTION="$(awk -v ver="${PLUGIN_VERSION}" '
$0 ~ "^## \\[" ver "\\]" { capture = 1; next }
capture && /^## / { exit }
capture { print }
' CHANGELOG.md)"
fi
cat > release_body.md <<EOF
## ${PLUGIN_NAME} v${PLUGIN_VERSION}
Built on top of [rust-samp ${SDK_VERSION}](https://github.com/NullSablex/rust-samp/releases/tag/${SDK_VERSION}).
### Artifacts
- \`${PLUGIN_NAME}.so\` — Linux i686 (\`i686-unknown-linux-gnu\`).
- \`${PLUGIN_NAME}.dll\` — Windows i686 (\`i686-pc-windows-msvc\`).
- \`${PLUGIN_NAME}.inc\` — Pawn include, identical file for SA-MP and Open Multiplayer.
### Compatibility
The binaries are **universal**: they run on SA-MP and on Open Multiplayer, on Linux and Windows alike.
- **SA-MP**: register under \`plugins=\` in \`server.cfg\`.
- **Open Multiplayer (native mode, recommended)**: register as a component under \`components\` in \`config.json\`. Loaded via \`ComponentEntryPoint\`, with access to \`ICore\`, \`ITimersComponent\` and the remaining native APIs.
- **Open Multiplayer (legacy mode)**: still supported — register under \`legacy_plugins\` (or the equivalent key in your \`config.json\`) if you prefer the SA-MP compat path over the native component. Same binary, no extra build flags.
EOF
if [ -n "${CHANGELOG_SECTION}" ]; then
{
echo ""
echo "### Changelog"
echo ""
echo "${CHANGELOG_SECTION}"
} >> release_body.md
fi
cat release_body.md
- name: Upload release assets
uses: softprops/action-gh-release@v3
with:
body_path: release_body.md
append_body: true
files: |
dist/${{ env.PLUGIN_NAME }}.so
dist/${{ env.PLUGIN_NAME }}.dll
dist/${{ env.PLUGIN_NAME }}.inc