-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (136 loc) · 5.04 KB
/
build.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
name: Build, Test, and Publish Pseudolang
on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:
permissions: write-all
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run Tests
run: cargo test --verbose
build:
name: Build Multi-Platform
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Install Cross
run: cargo install cross
- name: Build Release
run: cross build --release --target ${{ matrix.target }}
- name: Prepare Artifacts
run: |
mkdir -p release
mkdir -p installer
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
cp target/${{ matrix.target }}/release/fplc.exe release/fplc-x64.exe
cp release/fplc-x64.exe installer/fplc.exe
cp LICENSE installer/
else
cp target/${{ matrix.target }}/release/fplc release/fplc-linux-x64
chmod +x release/fplc-linux-x64
fi
- name: Install NSIS
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt-get update
sudo apt-get install -y nsis
- name: Build Windows Installer
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
mkdir -p release/installer
makensis installer/pseudolang.nsi
cp release/installer/pseudolang-setup-x64.exe release/
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: pseudolang-${{ matrix.target }}
path: release/*
retention-days: 7
if-no-files-found: error
- name: Upload Installer Artifact
if: matrix.target == 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v4
with:
name: pseudolang-installer
path: release/installer/pseudolang-setup-x64.exe
retention-days: 7
if-no-files-found: error
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write
pull-requests: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '.') && startsWith(github.event.head_commit.message, '0.') || startsWith(github.event.head_commit.message, '1.') || startsWith(github.event.head_commit.message, '2.') || startsWith(github.event.head_commit.message, '3.') || startsWith(github.event.head_commit.message, '4.') || startsWith(github.event.head_commit.message, '5.') || startsWith(github.event.head_commit.message, '6.') || startsWith(github.event.head_commit.message, '7.') || startsWith(github.event.head_commit.message, '8.') || startsWith(github.event.head_commit.message, '9.')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create Git Tag
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
TAG_NAME=$(git log -1 --pretty=%s | grep -oE '\b[0-9]+\.[0-9]+\.[0-9]+\b')
TAG_NAME="v${TAG_NAME}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists. Skipping tag creation."
else
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: pseudolang-x86_64-pc-windows-gnu
path: artifacts/windows
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: pseudolang-x86_64-unknown-linux-gnu
path: artifacts/linux
- name: Prepare Release Files
run: |
mkdir -p release
cp artifacts/windows/fplc-x64.exe release/
cp artifacts/windows/pseudolang-setup-x64.exe release/ || true
cp artifacts/linux/fplc-linux-x64 release/
chmod +x release/fplc-linux-x64
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TAG_NAME }}
name: Pseudolang ${{ env.TAG_NAME }}
body: |
See the full changelog: https://github.com/${{ github.repository }}/compare/${{ env.TAG_NAME }}~1...${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}