fvtt-never-stop-blowing-up/.gitlab-ci.yml
2024-09-23 16:09:50 +00:00

108 lines
3.4 KiB
YAML

stages:
- compile
- release
# Compile Job (runs on every commit)
compile:
stage: compile
image: ubuntu:latest
before_script:
# Install Node.js v21.x manually
- apt-get update && apt-get install -y curl
- curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
- apt-get install -y nodejs
- node -v # Verify the correct Node.js version
# Install Gulp globally
- npm install --global gulp-cli
- gulp --version # Verify Gulp is installed
script:
- npm install
- gulp compile
only:
- branches
artifacts:
paths:
- kidsonbrooms.zip
expire_in: never
# Release Job (manually triggered with version)
release:
stage: release
image: ubuntu:latest
before_script:
# Install necessary tools
- apt-get update && apt-get install -y curl jq git
# Install Node.js v21.x manually
- curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
- apt-get install -y nodejs
- node -v # Verify the correct Node.js version
# Install Gulp globally
- npm install --global gulp-cli
- gulp --version # Verify Gulp is installed
# Install release-cli
- curl -sSL -o /usr/local/bin/release-cli https://gitlab.com/gitlab-org/release-cli/-/releases/v0.17.0/downloads/release-cli-linux-amd64
- chmod +x /usr/local/bin/release-cli
- release-cli --version
- git fetch --all
- git switch master
- git branch --set-upstream-to=origin/master master
script:
# Check if VERSION is provided
- |
if [ -z "$VERSION" ]; then
echo "Error: VERSION variable is required."
exit 1
fi
# Install dependencies and run Gulp release task
- npm install
- gulp release
# Update system.json with the release URL
- |
sed -i "s|\"download\":.*|\"download\": \"https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/releases/v$VERSION/download\",|" system.json
- grep '"download":' system.json
- git config --global user.name "GitLab CI"
- git config --global user.email "ci@gitlab.com"
- git add system.json
- git commit -m "Update system.json with release URL"
- git push "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git" HEAD:master
# Publish the release to the Foundry API
- |
curl -X POST https://api.foundryvtt.com/_api/packages/release_version/ \
-H "Authorization: $FOUNDRY_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"id\": \"Your-Package-ID\",
\"release\": {
\"version\": \"$VERSION\",
\"manifest\": \"https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/raw/master/system.json\",
\"notes\": \"https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/v$VERSION\",
\"compatibility\": {
\"minimum\": \"12.331\",
\"verified\": \"12.331\",
\"maximum\": \"\"
}
}
}"
only:
- master
when: manual
allow_failure: false
dependencies:
- compile
artifacts:
paths:
- kidsonbrooms.zip
expire_in: never
release:
name: "Release v$VERSION"
tag_name: "v$VERSION"
description: "Release v$VERSION"
ref: master
assets:
links:
- name: "Download kidsonbrooms.zip"
url: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts/raw/kidsonbrooms.zip"