Skip to content

Commit 885541b

Browse files
committed
this is so damn annoying I HATE WORKFLOWS
1 parent 9eccdfe commit 885541b

1 file changed

Lines changed: 136 additions & 71 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 136 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,140 @@ permissions:
1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
20-
20+
strategy:
21+
matrix:
22+
sm-version: [ '1.12' ]
23+
24+
name: "Build for SM ${{ matrix.sm-version }}"
25+
if: github.ref_type == 'tag'
2126
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 0
26-
27-
- name: Make compile script and compiler executable
28-
run: |
29-
chmod +x compile.sh
30-
chmod +x spcomp spcomp64
31-
32-
- name: Compile plugin
33-
run: ./compile.sh offstyledb.sp
34-
35-
- name: Check if compiled file exists
36-
run: |
37-
if [ ! -f "./compiled/offstyledb.smx" ]; then
38-
echo "Error: Compiled plugin not found!"
39-
exit 1
40-
fi
41-
ls -la compiled/
42-
43-
- name: Get tag name
44-
id: get_tag
45-
run: |
46-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
47-
echo "tag_name=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
48-
else
49-
echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
50-
fi
51-
52-
- name: Generate changelog
53-
id: changelog
54-
run: |
55-
current_tag=${{ steps.get_tag.outputs.tag_name }}
56-
previous_tag=$(git tag --sort=-version:refname | head -n 2 | tail -n 1 || echo "")
57-
if [ -n "$previous_tag" ]; then
58-
commits=$(git log --oneline $previous_tag..$current_tag)
59-
body="Automated release of Offstyle Database plugin
60-
61-
## Changes
62-
$commits
63-
64-
## Installation
65-
1. Download \`offstyledb.smx\`
66-
2. Upload to your SourceMod plugins directory
67-
3. Restart your server or use \`sm plugins reload offstyledb\`"
68-
else
69-
body="Automated release of Offstyle Database plugin
70-
71-
## Changes
72-
- Initial release
73-
74-
## Installation
75-
1. Download \`offstyledb.smx\`
76-
2. Upload to your SourceMod plugins directory
77-
3. Restart your server or use \`sm plugins reload offstyledb\`"
78-
fi
79-
echo "body<<EOF" >> $GITHUB_OUTPUT
80-
echo "$body" >> $GITHUB_OUTPUT
81-
echo "EOF" >> $GITHUB_OUTPUT
82-
83-
- name: Create Release
84-
uses: softprops/action-gh-release@v1
85-
with:
86-
tag_name: ${{ steps.get_tag.outputs.tag_name }}
87-
name: Release ${{ steps.get_tag.outputs.tag_name }}
88-
body: ${{ steps.changelog.outputs.body }}
89-
files: ./compiled/offstyledb.smx
90-
draft: false
91-
prerelease: false
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup SP
33+
uses: rumblefrog/setup-sp@master
34+
with:
35+
version: ${{ matrix.sm-version }}
36+
37+
- name: Download ripext dependency
38+
shell: bash
39+
run: |
40+
# Mac zip just because it's smaller & we don't repack the extensions...
41+
wget https://github.com/ErikMinekus/sm-ripext/releases/download/1.3.1/sm-ripext-1.3.1-mac.zip
42+
unzip sm-ripext-1.3.1-mac.zip "addons/sourcemod/scripting/include/*"
43+
44+
45+
- name: Run compiler
46+
shell: bash
47+
run: |
48+
cd addons/sourcemod
49+
mkdir -p plugins
50+
for src in $(find scripting -maxdepth 1 -type f -name "*.sp");
51+
do
52+
spcomp $src -o=plugins/$(basename $src .sp)'.smx' -i=scripting/include -v2
53+
done
54+
55+
- name: Upload artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: offstyle-database-${{ github.head_ref || github.ref_name }}-sm${{ matrix.sm-version }}-${{ env.GITHUB_SHA_SHORT }}
59+
path: |
60+
addons
61+
retention-days: 14
62+
63+
release:
64+
name: Release
65+
if: github.ref_type == 'tag'
66+
needs: build
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Download artifacts
75+
uses: actions/download-artifact@v4
76+
77+
- name: Archive artifacts
78+
shell: bash
79+
run: |
80+
find * -maxdepth 0 -type d -exec zip -rq {}.zip {} \;
81+
echo "zip_file=$(ls *.zip | head -n 1)" >> $GITHUB_ENV
82+
83+
- name: Generate changelog
84+
id: changelog
85+
run: |
86+
current_tag=${{ github.ref_name }}
87+
previous_tag=$(git tag --sort=-version:refname | head -n 2 | tail -n 1 || echo "")
88+
if [ -n "$previous_tag" ]; then
89+
commits=$(git log --oneline $previous_tag..$current_tag)
90+
body="Automated release of Offstyle Database plugin
91+
92+
## Changes
93+
$commits
94+
95+
## Installation
96+
1. Download and extract the zip file
97+
2. Upload the contents to your server
98+
3. Restart your server or reload the plugins
99+
100+
## Files included
101+
- Compiled plugins in \`addons/sourcemod/plugins/\`
102+
- Source files in \`addons/sourcemod/scripting/\`"
103+
else
104+
body="Automated release of Offstyle Database plugin
105+
106+
## Changes
107+
- Initial release
108+
109+
## Installation
110+
1. Download and extract the zip file
111+
2. Upload the contents to your server
112+
3. Restart your server or reload the plugins
113+
114+
## Files included
115+
- Compiled plugins in \`addons/sourcemod/plugins/\`
116+
- Source files in \`addons/sourcemod/scripting/\`"
117+
fi
118+
echo "body<<EOF" >> $GITHUB_OUTPUT
119+
echo "$body" >> $GITHUB_OUTPUT
120+
echo "EOF" >> $GITHUB_OUTPUT
121+
122+
- name: Create Release
123+
id: create_release
124+
uses: ncipollo/release-action@v1
125+
with:
126+
token: ${{ secrets.GITHUB_TOKEN }}
127+
tag: ${{ github.ref_name }}
128+
name: Release ${{ github.ref_name }}
129+
body: ${{ steps.changelog.outputs.body }}
130+
artifacts: "*.zip"
131+
draft: false
132+
prerelease: false
133+
134+
notify:
135+
name: Discord Notification
136+
if: github.ref_type == 'tag'
137+
needs: release
138+
runs-on: ubuntu-latest
139+
steps:
140+
- name: Download artifacts
141+
uses: actions/download-artifact@v4
142+
143+
- name: Get zip file
144+
shell: bash
145+
run: |
146+
find * -maxdepth 0 -type d -exec zip -rq {}.zip {} \;
147+
echo "zip_file=$(ls *.zip | head -n 1)" >> $GITHUB_ENV
148+
149+
- name: Notify Discord
150+
uses: tsickert/discord-webhook@v7.0.0
151+
with:
152+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
153+
filename: ${{ env.zip_file }}
154+
content: |
155+
the releaser?
156+
${{ steps.changelog.outputs.body }}

0 commit comments

Comments
 (0)