initial ci
All checks were successful
ci / ci (push) Successful in 24s

This commit is contained in:
Arindy 2025-03-01 19:28:34 +01:00
parent ad372a6271
commit db2b8dfcd6
4 changed files with 97 additions and 19 deletions

87
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,87 @@
name: ci
on: [ push, pull_request ]
jobs:
ci:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
statuses: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- id: version
name: version
run: |
major=${{contains(github.event.head_commit.message, 'major')}}
minor=${{contains(github.event.head_commit.message, 'minor')}}
echo "major: " $major
echo "minor: " $minor
if ${{ github.ref_name == 'main' }}; then
echo "on main"
if [[ $major ]]; then
newVersion="major"
elif [[ $minor ]]; then
newVersion="minor"
else
newVersion="patch"
fi
else
if [[ $major ]]; then
newVersion="premajor"
elif [[ $minor ]]; then
newVersion="preminor"
else
newVersion="prepatch"
fi
fi
echo "using: " $newVersion
npm version "$newVersion" --git-tag-version=false
echo "VERSION=$(npm --silent run version)" >> ${GITHUB_OUTPUT}
- name: npm ci
run: npm ci
- name: build
run: npm run build
- name: zip release
if: github.ref_name == 'main'
working-directory: dist
run: zip -r foundryvtt-dice-tower-${{ steps.version.outputs.VERSION }}.zip .
# - name: create tag
# if: github.ref_name == 'main'
# run: |
# git config user.email "ci@git.arindy.de"
# git config user.name "gitea"
# git add package.json
# git add package-lock.json
# git commit -m "[no ci] ${{ steps.version.outputs.VERSION }}"
# git tag ${{ steps.version.outputs.VERSION }} -m "release ${{ steps.version.outputs.VERSION }}"
# git push origin main
# git push origin ${{ steps.version.outputs.VERSION }}
#
# - name: release
# if: github.ref_name == 'main'
# uses: akkuman/gitea-release-action@v1
# env:
# NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
# with:
# files: |-
# dist/foundryvtt-dice-tower-${{ steps.version.outputs.VERSION }}.zip
# dist/module.json
# tag_name: ${{ steps.version.outputs.VERSION }}
# name: Release ${{ steps.version.outputs.VERSION }}

8
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "dice-tower-foundry", "name": "foundryvtt-dice-tower",
"version": "1.0.0", "version": "0.0.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dice-tower-foundry", "name": "foundryvtt-dice-tower",
"version": "1.0.0", "version": "0.0.1",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"devDependencies": { "devDependencies": {
"@3d-dice/dice-box-threejs": "^0.0.12", "@3d-dice/dice-box-threejs": "^0.0.12",

View File

@ -1,6 +1,6 @@
{ {
"name": "foundryvtt-dice-tower", "name": "foundryvtt-dice-tower",
"version": "1.0.0", "version": "0.0.1",
"description": "Roll your dice in a fancy overlay", "description": "Roll your dice in a fancy overlay",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {
@ -8,6 +8,7 @@
"build": "npm run clean && tsc && vite build", "build": "npm run clean && tsc && vite build",
"watch": "tsc && vite build --watch", "watch": "tsc && vite build --watch",
"copy": "sudo rsync -avP dist/ .foundry/data/Data/modules/dice-tower/", "copy": "sudo rsync -avP dist/ .foundry/data/Data/modules/dice-tower/",
"version": "echo $npm_package_version",
"buildCopy": "npm run build && npm run copy" "buildCopy": "npm run build && npm run copy"
}, },
"devDependencies": { "devDependencies": {

View File

@ -3,10 +3,6 @@ import copy from "rollup-plugin-copy";
import scss from "rollup-plugin-scss"; import scss from "rollup-plugin-scss";
import {defineConfig, Plugin} from "vite"; import {defineConfig, Plugin} from "vite";
const moduleVersion = process.env.MODULE_VERSION;
const githubProject = process.env.GH_PROJECT;
const githubTag = process.env.GH_TAG;
export default defineConfig({ export default defineConfig({
build: { build: {
sourcemap: true, sourcemap: true,
@ -46,7 +42,7 @@ function updateModuleManifestPlugin(): Plugin {
const packageContents = JSON.parse( const packageContents = JSON.parse(
await fsPromises.readFile("./package.json", "utf-8") await fsPromises.readFile("./package.json", "utf-8")
) as Record<string, unknown>; ) as Record<string, unknown>;
const version = moduleVersion || (packageContents.version as string); const version = (packageContents.version as string);
const description = (packageContents.description as string); const description = (packageContents.description as string);
const manifestContents: string = await fsPromises.readFile( const manifestContents: string = await fsPromises.readFile(
"src/module.json", "src/module.json",
@ -58,15 +54,9 @@ function updateModuleManifestPlugin(): Plugin {
>; >;
manifestJson["version"] = version; manifestJson["version"] = version;
manifestJson["description"] = description; manifestJson["description"] = description;
if (githubProject) { const baseUrl = `https://git.arindy.de/arindy/foundryvtt-dice-tower/releases/download`;
const baseUrl = `https://github.com/${githubProject}/releases`; manifestJson["manifest"] = `${baseUrl}/latest/module.json`;
manifestJson["manifest"] = `${baseUrl}/latest/download/module.json`; manifestJson["download"] = `${baseUrl}/${version}/foundryvtt-dice-tower-${version}.zip`;
if (githubTag) {
manifestJson[
"download"
] = `${baseUrl}/download/${githubTag}/module.zip`;
}
}
await fsPromises.writeFile( await fsPromises.writeFile(
"dist/module.json", "dist/module.json",
JSON.stringify(manifestJson, null, 4) JSON.stringify(manifestJson, null, 4)