|
1 | | -name: Build and Release |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: "0 0 * * *" |
6 | 4 | workflow_dispatch: |
7 | | - inputs: |
8 | | - nightly: |
9 | | - description: "Trigger a nightly build" |
10 | | - required: false |
11 | | - default: false |
12 | | - type: boolean |
13 | 5 |
|
14 | 6 | jobs: |
15 | | - check: |
| 7 | + validate: |
16 | 8 | 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 |
22 | 9 |
|
23 | 10 | steps: |
24 | | - - name: Validate CI status |
| 11 | + - name: Validate branch format |
25 | 12 | 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 }}" |
29 | 14 |
|
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)" |
32 | 18 | exit 1 |
33 | 19 | fi |
34 | 20 |
|
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