Add CI
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 3m55s
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 3m55s
This commit is contained in:
parent
5322944ad9
commit
a079298433
2 changed files with 52 additions and 9 deletions
|
@ -1,7 +1,9 @@
|
||||||
name: Create Release on Tag Push
|
name: Build on Push and create Release on Tag
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
|
@ -28,6 +30,12 @@ jobs:
|
||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
|
# Validate Tag Matches JSON Versions
|
||||||
|
- name: Validate Tag Matches JSON Versions
|
||||||
|
if: github.ref_type == 'tag'
|
||||||
|
run: |
|
||||||
|
node scripts/validate_tag.cjs ${{ github.ref }}
|
||||||
|
|
||||||
# Get pnpm store directory
|
# Get pnpm store directory
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
id: pnpm-cache
|
id: pnpm-cache
|
||||||
|
@ -52,11 +60,22 @@ jobs:
|
||||||
- name: Build for production
|
- name: Build for production
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
||||||
- name: Release
|
# Move file
|
||||||
uses: ncipollo/release-action@v1
|
- name: Move file
|
||||||
|
run: mkdir built; mv package.zip built/package.zip
|
||||||
|
|
||||||
|
# Upload artifacts
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
allowUpdates: true
|
path: built/package.zip
|
||||||
artifactErrorsFailBuild: true
|
overwrite: true
|
||||||
artifacts: "package.zip"
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
# Create Forgejo Release
|
||||||
prerelease: false
|
- name: Create Forgejo Release
|
||||||
|
if: github.ref_type == 'tag'
|
||||||
|
uses: actions/forgejo-release@v1
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
release-dir: built
|
||||||
|
token: ${{ secrets.FORGE_TOKEN }}
|
24
scripts/validate_tag.cjs
Normal file
24
scripts/validate_tag.cjs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const [tagName] = process.argv.slice(2); // Get tag from CLI arguments
|
||||||
|
if (!tagName) {
|
||||||
|
console.error('Error: No tag name provided.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TAG_VERSION = tagName.replace('refs/tags/v', '');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
||||||
|
const pluginJson = JSON.parse(fs.readFileSync(path.resolve('plugin.json'), 'utf8'));
|
||||||
|
|
||||||
|
if (TAG_VERSION !== packageJson.version || TAG_VERSION !== pluginJson.version) {
|
||||||
|
console.error(`Error: Tag version (${TAG_VERSION}) does not match package.json (${packageJson.version}) or plugin.json (${pluginJson.version})`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log('Tag version matches both JSON files.');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to read or parse JSON files:', err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue