-
Notifications
You must be signed in to change notification settings - Fork 39
140 lines (119 loc) · 4.13 KB
/
release-common.yml
File metadata and controls
140 lines (119 loc) · 4.13 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
name: release-common
on:
workflow_call:
inputs:
branch:
description: "Branch to use for the release. 'primary' triggers a nightly build."
required: false
default: "primary"
type: string
env:
IS_NIGHTLY: ${{ inputs.branch == 'primary' }}
jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Validate CI status
id: check
run: |
LAST_STATUS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/luau-lang/lute/actions/workflows/ci.yml/runs?branch=${{ inputs.branch }}&status=completed&per_page=1" \
| jq -r '.workflow_runs[0].conclusion')
if [[ "$LAST_STATUS" != "success" ]]; then
echo "The latest CI run on '${{ inputs.branch }}' branch did not succeed. Aborting release."
exit 1
fi
build:
strategy:
matrix:
include:
- os: ubuntu-22.04
artifact_name: lute-linux-x86_64
options: --c-compiler clang --cxx-compiler clang++
- os: ubuntu-22.04-arm
artifact_name: lute-linux-aarch64
options: --c-compiler clang --cxx-compiler clang++
use-bootstrap: true
- os: macos-latest
artifact_name: lute-macos-aarch64
- os: windows-latest
artifact_name: lute-windows-x86_64
fail-fast: false
needs: check
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Set nightly version suffix
if: ${{ env.IS_NIGHTLY == 'true' }}
run: echo "LUTE_VERSION_SUFFIX=nightly.$(date +%Y%m%d)" >> "$GITHUB_ENV"
- name: Setup and Build Lute
id: build_lute
uses: ./.github/actions/setup-and-build
with:
target: Lute.CLI
config: release
options: ${{ matrix.options }}
token: ${{ secrets.GITHUB_TOKEN }}
use-bootstrap: ${{ matrix.use-bootstrap || 'false' }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: ${{ steps.build_lute.outputs.exe_path }}
name: ${{ matrix.artifact_name }}
release:
needs: [check, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
sparse-checkout: CMakeBuild/get_version.cmake
- name: Set nightly version suffix
if: ${{ env.IS_NIGHTLY == 'true' }}
run: echo "LUTE_VERSION_SUFFIX=nightly.$(date +%Y%m%d)" >> "$GITHUB_ENV"
- name: Download Artifact
uses: actions/download-artifact@v4
with:
path: artifacts
- run: |
mkdir release
for dir in ./artifacts/*; do
base_name=$(basename "$dir")
chmod 755 "$dir"/* # Artifacts don't preserve permissions, so re-add them.
zip -rj release/"${base_name}.zip" "$dir"/*
done
- name: Get project version
id: get_version
run: |
VERSION=$(cmake -P CMakeBuild/get_version.cmake 2>&1)
echo "Resolved version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create release tag
id: tag_release
run: |
TAG="v${{ steps.get_version.outputs.version }}"
echo "Release tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Create Draft Release
uses: luau-lang/action-gh-release@v2
with:
tag_name: ${{ steps.tag_release.outputs.tag }}
name: ${{ steps.tag_release.outputs.tag }}
draft: true
prerelease: ${{ env.IS_NIGHTLY == 'true' }}
generate_release_notes: ${{ env.IS_NIGHTLY == 'true' }}
files: release/*.zip
- name: Wait for Tag Creation in GitHub
run: sleep 5
- name: Publish Release
run: gh release edit "${{ steps.tag_release.outputs.tag }}" --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}