mirror of
https://github.com/VibedByKaKi/zt64-aliucord-plugins.git
synced 2026-08-20 13:21:15 +02:00
Remove pushes to builds and dev-builds branches. Deploy workflows now publish GitHub Actions artifacts and dev prereleases only. Co-authored-by: KaKi87 <KaKi87@pm.me>
99 lines
2.9 KiB
YAML
99 lines
2.9 KiB
YAML
name: "Deploy"
|
|
|
|
concurrency:
|
|
group: "deploy"
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- ".github/workflows/**"
|
|
- "gradle.properties"
|
|
- "gradle/**"
|
|
- "plugin/**"
|
|
- "**.gradle.kts"
|
|
|
|
permissions:
|
|
actions: write
|
|
contents: read
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Build & Publish Plugins
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
|
|
|
|
- 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 generateUpdaterJson
|
|
|
|
- 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})`);
|
|
}
|
|
|
|
const updater = path.join(workspace, 'build', 'outputs', 'updater.json');
|
|
if (!fs.existsSync(updater)) {
|
|
throw new Error(`Missing updater.json: ${updater}`);
|
|
}
|
|
|
|
console.log('Uploading updater.json');
|
|
const { id, size } = await client.uploadArtifact(
|
|
'updater.json',
|
|
[updater],
|
|
workspace,
|
|
{ skipArchive: true }
|
|
);
|
|
console.log(`Uploaded updater.json (id: ${id}, bytes: ${size})`);
|