zt64-aliucord-plugins/.github/workflows/deploy-dev.yml
Cursor Agent d4e2490e70
ci: publish immutable dev prereleases alongside stable dev tag
Keep updating the floating dev release for a stable download URL, and also
create a new prerelease on each deploy tagged dev-<run_number> with a
matching updater.json that points at that release's assets.

Co-authored-by: KaKi87 <KaKi87@pm.me>
2026-08-06 22:50:15 +00:00

145 lines
4.9 KiB
YAML

name: "Deploy Dev"
concurrency:
group: "deploy-dev"
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- dev
paths:
- ".github/workflows/**"
- "gradle.properties"
- "gradle/**"
- "plugin/**"
- "**.gradle.kts"
permissions:
actions: write
contents: write
jobs:
deploy-dev:
name: Build & Publish Dev Plugins
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
- 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: Prepare release files
run: |
mkdir -p dist dist-versioned
cp plugin/*/build/outputs/*.zip dist/
cp plugin/*/build/outputs/*.zip dist-versioned/
cp build/outputs/updater.json dist/updater.json
cp build/outputs/updater.json dist-versioned/updater.json
sed -i "s|https://raw.githubusercontent.com/[^/]*/[^/]*/builds/|https://github.com/${GITHUB_REPOSITORY}/releases/download/dev/|g" dist/updater.json
sed -i "s|https://raw.githubusercontent.com/[^/]*/[^/]*/builds/|https://github.com/${GITHUB_REPOSITORY}/releases/download/dev-${GITHUB_RUN_NUMBER}/|g" dist-versioned/updater.json
- 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, 'dist', '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})`);
- name: Update dev release tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -fa dev -m "Dev prerelease (${{ github.sha }})"
git push origin refs/tags/dev --force
- name: Publish stable dev prerelease
uses: softprops/action-gh-release@v2
with:
tag_name: dev
target_commitish: ${{ github.sha }}
name: Dev prerelease (${{ github.sha }})
prerelease: true
make_latest: false
generate_release_notes: true
overwrite_files: true
files: |
${{ github.workspace }}/dist/*.zip
${{ github.workspace }}/dist/updater.json
- name: Publish versioned dev prerelease
uses: softprops/action-gh-release@v2
with:
tag_name: dev-${{ github.run_number }}
target_commitish: ${{ github.sha }}
name: Dev prerelease #${{ github.run_number }} (${{ github.sha }})
prerelease: true
make_latest: false
generate_release_notes: true
files: |
${{ github.workspace }}/dist-versioned/*.zip
${{ github.workspace }}/dist-versioned/updater.json