mirror of
https://github.com/VibedByKaKi/zt64-aliucord-plugins.git
synced 2026-08-21 05:41:15 +02:00
Reject manual Build runs on dev/main with a clear error pointing to Deploy Dev. Force-update the dev release tag before publishing so prereleases track the latest dev commit. Co-authored-by: KaKi87 <KaKi87@pm.me>
93 lines
2.8 KiB
YAML
93 lines
2.8 KiB
YAML
name: "Build"
|
|
|
|
concurrency:
|
|
group: "build-${{ github.ref }}"
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches-ignore:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- ".github/workflows/**"
|
|
- "gradle.properties"
|
|
- "gradle/**"
|
|
- "plugin/**"
|
|
- "**.gradle.kts"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Plugins
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
permissions:
|
|
actions: write
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Reject deploy branches
|
|
if: github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
|
|
run: |
|
|
echo "::error::The Build workflow does not publish releases. Use the Deploy Dev workflow on dev, or Deploy on main."
|
|
exit 1
|
|
|
|
- name: Setup JDK 21
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: 21
|
|
distribution: temurin
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
|
|
- name: Build plugins
|
|
run: |
|
|
chmod +x ./gradlew
|
|
./gradlew make
|
|
|
|
- name: Install artifact client
|
|
run: npm install --no-save @actions/artifact@6
|
|
|
|
- name: Upload plugin artifacts
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { DefaultArtifactClient } = require(`${process.env.GITHUB_WORKSPACE}/node_modules/@actions/artifact`);
|
|
|
|
const client = new DefaultArtifactClient();
|
|
const workspace = process.env.GITHUB_WORKSPACE;
|
|
const pluginDir = path.join(workspace, 'plugin');
|
|
|
|
const plugins = fs.readdirSync(pluginDir, { withFileTypes: true })
|
|
.filter((entry) => entry.isDirectory())
|
|
.map((entry) => entry.name);
|
|
|
|
if (plugins.length === 0) {
|
|
throw new Error('No plugins found');
|
|
}
|
|
|
|
for (const plugin of plugins) {
|
|
const zip = path.join(pluginDir, plugin, 'build', 'outputs', `${plugin}.zip`);
|
|
if (!fs.existsSync(zip)) {
|
|
throw new Error(`Missing build output: ${zip}`);
|
|
}
|
|
|
|
console.log(`Uploading ${plugin}`);
|
|
const { id, size } = await client.uploadArtifact(
|
|
plugin,
|
|
[zip],
|
|
workspace,
|
|
{ skipArchive: true }
|
|
);
|
|
console.log(`Uploaded ${plugin} (id: ${id}, bytes: ${size})`);
|
|
}
|