Skip to content

Commit 12fdb89

Browse files
committed
Sets up a release job for Lute
1 parent 0a9047d commit 12fdb89

File tree

5 files changed

+239
-176
lines changed

5 files changed

+239
-176
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: ["primary"]
5+
branches: ["primary", "release/**"]
66
pull_request:
77
branches: ["primary"]
88

.github/workflows/nightly.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Nightly Release
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
changes:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
proceed: ${{ steps.check.outputs.proceed }}
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Check for changes since last nightly tag
21+
id: check
22+
run: |
23+
PROCEED="true"
24+
25+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
26+
echo "Schedule trigger: Checking changes..."
27+
28+
LATEST_NIGHTLY_TAG=$(git tag --sort=-creatordate --list '*-nightly.*' | head -n 1)
29+
30+
if [[ -n "$LATEST_NIGHTLY_TAG" ]]; then
31+
echo "Latest nightly tag found: $LATEST_NIGHTLY_TAG"
32+
LATEST_NIGHTLY_COMMIT=$(git rev-list -n 1 "$LATEST_NIGHTLY_TAG" 2>/dev/null)
33+
CURRENT_HEAD_COMMIT=$(git rev-parse HEAD)
34+
35+
echo "Commit for tag $LATEST_NIGHTLY_TAG: $LATEST_NIGHTLY_COMMIT"
36+
echo "Current HEAD commit: $CURRENT_HEAD_COMMIT"
37+
38+
if [[ "$LATEST_NIGHTLY_COMMIT" == "$CURRENT_HEAD_COMMIT" ]]; then
39+
echo "No code changes detected since the last nightly release ($LATEST_NIGHTLY_TAG)."
40+
PROCEED="false"
41+
else
42+
echo "Code changes detected since $LATEST_NIGHTLY_TAG. Proceeding with build."
43+
fi
44+
else
45+
echo "No previous nightly tag found. Proceeding with build."
46+
fi
47+
else
48+
echo "Manual trigger. Proceeding with build."
49+
fi
50+
51+
echo "proceed=$PROCEED" >> $GITHUB_OUTPUT
52+
53+
build-and-release:
54+
needs: changes
55+
if: ${{ needs.changes.outputs.proceed == 'true' }}
56+
uses: ./.github/workflows/shared-build.yml
57+
with:
58+
branch: primary
59+
secrets: inherit

.github/workflows/release.yml

Lines changed: 13 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,26 @@
1-
name: Build and Release
1+
name: Release
22

33
on:
4-
schedule:
5-
- cron: "0 0 * * *"
64
workflow_dispatch:
7-
inputs:
8-
nightly:
9-
description: "Trigger a nightly build"
10-
required: false
11-
default: false
12-
type: boolean
135

146
jobs:
15-
check:
7+
validate:
168
runs-on: ubuntu-latest
17-
outputs:
18-
proceed: ${{ steps.check.outputs.proceed }}
19-
nightly_tag: ${{ steps.set_nightly.outputs.nightly_tag }}
20-
permissions:
21-
contents: read
229

2310
steps:
24-
- name: Validate CI status
11+
- name: Validate branch format
2512
run: |
26-
LAST_STATUS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
27-
"https://api.github.com/repos/luau-lang/lute/actions/workflows/ci.yml/runs?branch=primary&status=completed&per_page=1" \
28-
| jq -r '.workflow_runs[0].conclusion')
13+
BRANCH="${{ github.ref_name }}"
2914
30-
if [[ "$LAST_STATUS" != "success" ]]; then
31-
echo "The latest CI run on 'primary' branch did not succeed. Aborting release."
15+
if [[ ! "$BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
16+
echo "Invalid branch format: $BRANCH. Expected release/v{Major}.{Minor}.x"
17+
echo "Dispatch this workflow on a release branch (e.g. release/v0.1.x)"
3218
exit 1
3319
fi
3420
35-
- name: Checkout code
36-
uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
39-
40-
- name: Check for changes since last nightly tag
41-
id: check
42-
run: |
43-
PROCEED="true"
44-
45-
if [[ "${{ github.event_name }}" == "schedule" ]]; then
46-
echo "Schedule trigger: Checking changes..."
47-
48-
LATEST_NIGHTLY_TAG=$(git tag --sort=-creatordate --list '*-nightly.*' | head -n 1)
49-
50-
if [[ -n "$LATEST_NIGHTLY_TAG" ]]; then
51-
echo "Latest nightly tag found: $LATEST_NIGHTLY_TAG"
52-
LATEST_NIGHTLY_COMMIT=$(git rev-list -n 1 "$LATEST_NIGHTLY_TAG" 2>/dev/null)
53-
CURRENT_HEAD_COMMIT=$(git rev-parse HEAD)
54-
55-
echo "Commit for tag $LATEST_NIGHTLY_TAG: $LATEST_NIGHTLY_COMMIT"
56-
echo "Current HEAD commit: $CURRENT_HEAD_COMMIT"
57-
58-
if [[ "$LATEST_NIGHTLY_COMMIT" == "$CURRENT_HEAD_COMMIT" ]]; then
59-
echo "No code changes detected since the last nightly release ($LATEST_NIGHTLY_TAG)."
60-
PROCEED="false"
61-
else
62-
echo "Code changes detected since $LATEST_NIGHTLY_TAG. Proceeding with build."
63-
fi
64-
else
65-
echo "No previous nightly tag found. Proceeding with build."
66-
fi
67-
else
68-
echo "Manual trigger ('${{ github.event_name }}'). Proceeding with build."
69-
fi
70-
71-
echo "proceed=$PROCEED" >> $GITHUB_OUTPUT
72-
73-
- name: Set nightly version suffix
74-
id: set_nightly
75-
if: github.event_name == 'schedule' || github.event.inputs.nightly
76-
run: |
77-
DATE=$(date +%Y%m%d)
78-
echo "nightly_tag=nightly.$DATE" >> "$GITHUB_OUTPUT"
79-
80-
build:
81-
strategy:
82-
matrix:
83-
include:
84-
- os: ubuntu-22.04
85-
artifact_name: lute-linux-x86_64
86-
options: --c-compiler clang --cxx-compiler clang++
87-
- os: ubuntu-22.04-arm
88-
artifact_name: lute-linux-aarch64
89-
options: --c-compiler clang --cxx-compiler clang++
90-
use-bootstrap: true
91-
- os: macos-latest
92-
artifact_name: lute-macos-aarch64
93-
- os: windows-latest
94-
artifact_name: lute-windows-x86_64
95-
fail-fast: false
96-
97-
needs: check
98-
if: ${{ needs.check.outputs.proceed == 'true' }}
99-
runs-on: ${{ matrix.os }}
100-
101-
steps:
102-
- name: Checkout code
103-
uses: actions/checkout@v4
104-
105-
# Used for lute --version
106-
- name: Set nightly version suffix
107-
if: needs.check.outputs.nightly_tag
108-
run: echo "LUTE_VERSION_SUFFIX=${{ needs.check.outputs.nightly_tag }}" >> "$GITHUB_ENV"
109-
110-
- name: Setup and Build Lute
111-
id: build_lute
112-
uses: ./.github/actions/setup-and-build
113-
with:
114-
target: Lute.CLI
115-
config: release
116-
options: ${{ matrix.options }}
117-
token: ${{ secrets.GITHUB_TOKEN }}
118-
use-bootstrap: ${{ matrix.use-bootstrap || 'false' }}
119-
120-
- name: Upload Artifact
121-
uses: actions/upload-artifact@v4
122-
with:
123-
path: ${{ steps.build_lute.outputs.exe_path }}
124-
name: ${{ matrix.artifact_name }}
125-
126-
release:
127-
needs: [check, build]
128-
runs-on: ubuntu-latest
129-
130-
permissions:
131-
contents: write
132-
133-
steps:
134-
- name: Checkout code
135-
uses: actions/checkout@v4
136-
with:
137-
sparse-checkout: CMakeBuild/get_version.cmake
138-
139-
- name: Download Artifact
140-
uses: actions/download-artifact@v4
141-
with:
142-
path: artifacts
143-
144-
- run: |
145-
mkdir release
146-
for dir in ./artifacts/*; do
147-
base_name=$(basename "$dir")
148-
chmod 755 "$dir"/* # Artifacts don't preserve permissions, so re-add them.
149-
zip -rj release/"${base_name}.zip" "$dir"/*
150-
done
151-
152-
- name: Get project version
153-
id: get_version
154-
run: |
155-
VERSION=$(cmake -P CMakeBuild/get_version.cmake 2>&1)
156-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
157-
158-
- name: Create Nightly Tag
159-
id: tag_step
160-
if: needs.check.outputs.nightly_tag
161-
run: |
162-
echo "tag=-${{ needs.check.outputs.nightly_tag }}" >> $GITHUB_OUTPUT
163-
164-
- name: Create Release Tag
165-
id: tag_release
166-
run: |
167-
VERSION=${{ steps.get_version.outputs.version }}
168-
NIGHTLY_TAG=${{ steps.tag_step.outputs.tag }}
169-
RELEASE_TAG="$VERSION$NIGHTLY_TAG"
170-
echo "tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
171-
172-
- name: Create Draft Release
173-
uses: luau-lang/action-gh-release@v2
174-
with:
175-
tag_name: ${{ steps.tag_release.outputs.tag }}
176-
name: ${{ steps.tag_release.outputs.tag }}
177-
draft: true
178-
prerelease: ${{ github.event.inputs.nightly || github.event_name == 'schedule' }}
179-
generate_release_notes: true
180-
files: release/*.zip
181-
182-
- name: Wait for Tag Creation in GitHub
183-
run: sleep 5
184-
185-
- name: Publish Release
186-
run: gh release edit "${{ steps.tag_release.outputs.tag }}" --draft=false
187-
env:
188-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
build-and-release:
22+
needs: validate
23+
uses: ./.github/workflows/shared-build.yml
24+
with:
25+
branch: ${{ github.ref_name }}
26+
secrets: inherit

0 commit comments

Comments
 (0)