-
Notifications
You must be signed in to change notification settings - Fork 6
194 lines (188 loc) · 7.18 KB
/
Copy pathrelease.yml
File metadata and controls
194 lines (188 loc) · 7.18 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
release_tag:
description: Version used in dry-run artifact names
required: true
default: v1.0.0
permissions:
contents: read
jobs:
validate-tag:
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.tag.outputs.value }}
version: ${{ steps.tag.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: tag
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}
run: |
[[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || {
echo "release tag must use vMAJOR.MINOR.PATCH[-PRERELEASE]" >&2
exit 1
}
product_version=$(sed -n \
"s/^[[:space:]]*mooncompiler_version[[:space:]]*=[[:space:]]*'\([^']*\)';/\1/p" \
compiler/version.pas)
[[ -n "$product_version" && "$RELEASE_TAG" == "v$product_version" ]] || {
echo "tag $RELEASE_TAG does not match MoonCompiler $product_version" >&2
exit 1
}
echo "value=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "version=$product_version" >> "$GITHUB_OUTPUT"
linux-x86-64:
needs: validate-tag
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
RELEASE_TAG: ${{ needs.validate-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Install bootstrap
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
make binutils fp-compiler-3.2.2
test "$(fpc -iV)" = 3.2.2
- name: Build toolchain
run: ./build compiler
- name: Pack toolchain
run: |
mkdir -p dist
asset="mooncompiler-toolchain-${RELEASE_TAG}-linux-x86-64.tar.gz"
tar -czf "dist/$asset" -C .moonbot/toolchain .
- name: Install and smoke-test the archive
run: |
asset="dist/mooncompiler-toolchain-${RELEASE_TAG}-linux-x86-64.tar.gz"
mv .moonbot/toolchain .moonbot/toolchain.built
./build toolchain "$asset"
! grep -q 'toolchain\.new\.' .moonbot/toolchain/etc/fpc.cfg
! grep -q 'toolchain\.new\.' .moonbot/toolchain/ide/etc/fpc.cfg
test -x .moonbot/toolchain/bin/fpcres
test -x .moonbot/toolchain/ide/bin/fpcres
python3 qualification/build-driver/version_contract.py
./build examples/hello.dpr release
[[ "$(./examples/hello)" == '3 prices, sum = '* ]]
./build RTL-test/semantic/file_resource_semantic.dpr release
[[ "$(./RTL-test/semantic/file_resource_semantic)" == 'FILE_RESOURCE_PASS' ]]
- uses: actions/upload-artifact@v4
with:
name: toolchain-linux-x86-64
path: dist/*.tar.gz
if-no-files-found: error
compression-level: 0
win64-x86-64:
needs: validate-tag
runs-on: windows-2022
timeout-minutes: 90
env:
RELEASE_TAG: ${{ needs.validate-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Install FPC 3.2.2 bootstrap
shell: powershell
run: |
.\scripts\Install-FpcBootstrap.ps1 `
-Destination "$env:RUNNER_TEMP\fpc-3.2.2"
- name: Build toolchain
shell: powershell
run: |
.\build.ps1 compiler `
-Bootstrap "$env:RUNNER_TEMP\fpc-3.2.2\bin\i386-win32\fpc.exe"
- name: Pack toolchain
shell: powershell
run: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
New-Item -ItemType Directory -Force -Path dist | Out-Null
$Asset = "mooncompiler-toolchain-$env:RELEASE_TAG-win64.zip"
[IO.Compression.ZipFile]::CreateFromDirectory(
(Resolve-Path '.moonbot\toolchain').Path,
(Join-Path (Resolve-Path dist).Path $Asset),
[IO.Compression.CompressionLevel]::Optimal,
$false)
- name: Install and smoke-test the archive
shell: powershell
run: |
$Asset = "dist\mooncompiler-toolchain-$env:RELEASE_TAG-win64.zip"
Move-Item .moonbot\toolchain .moonbot\toolchain.built
.\build.ps1 toolchain $Asset
If (Select-String -Quiet -Pattern 'toolchain\.new\.' `
-Path .moonbot\toolchain\bin\x86_64-win64\fpc.cfg,
.moonbot\toolchain\ide\bin\x86_64-win64\fpc.cfg) {
throw 'installed configs still reference the staging path'
}
If (-not (Test-Path .moonbot\toolchain\bin\x86_64-win64\fpcres.exe) -or
-not (Test-Path .moonbot\toolchain\ide\bin\x86_64-win64\fpcres.exe)) {
throw 'the archive does not contain the resource compiler'
}
python .\qualification\build-driver\version_contract.py
.\build.ps1 .\examples\hello.dpr release
$Output = & .\examples\hello.exe
If ($Output -notlike '3 prices, sum = *') {
throw "archive smoke returned: $Output"
}
.\build.ps1 .\RTL-test\semantic\file_resource_semantic.dpr release
$Output = & .\RTL-test\semantic\file_resource_semantic.exe
If ($Output -ne 'FILE_RESOURCE_PASS') {
throw "resource smoke returned: $Output"
}
- uses: actions/upload-artifact@v4
with:
name: toolchain-win64-x86-64
path: dist/*.zip
if-no-files-found: error
compression-level: 0
publish:
needs: [validate-tag, linux-x86-64, win64-x86-64]
runs-on: ubuntu-24.04
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.validate-tag.outputs.tag }}
RELEASE_VERSION: ${{ needs.validate-tag.outputs.version }}
steps:
- uses: actions/download-artifact@v4
with:
pattern: toolchain-*
path: dist
merge-multiple: true
- name: Generate checksums
working-directory: dist
run: sha256sum mooncompiler-toolchain-* > SHA256SUMS
- name: Attest release assets
uses: actions/attest@v4
with:
subject-path: |
dist/*.zip
dist/*.tar.gz
dist/SHA256SUMS
- name: Publish GitHub Release
if: github.event_name == 'push'
run: |
release_options=(
"$RELEASE_TAG"
dist/mooncompiler-toolchain-*
dist/SHA256SUMS
--verify-tag
--title "MoonCompiler $RELEASE_VERSION"
--notes "Ready-to-install Win64 and Linux x86-64 toolchains. Clone the repository, download the matching archive, and follow the Quick Start in README.md. SHA256SUMS and GitHub artifact attestations are published with the binaries."
--generate-notes
)
[[ "$RELEASE_TAG" != *-* ]] || release_options+=(--prerelease)
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" \
dist/mooncompiler-toolchain-* dist/SHA256SUMS --clobber
else
gh release create "${release_options[@]}"
fi