fvtt-never-stop-blowing-up/.gitlab-ci.yml

111 lines
3.4 KiB
YAML
Raw Normal View History

2024-09-22 01:45:32 +02:00
stages:
- compile
- release
# Compile Job (runs on every commit)
compile:
stage: compile
2024-09-22 01:54:53 +02:00
image: ubuntu:latest
before_script:
2024-09-23 17:58:07 +02:00
# Install Node.js v21.x manually
2024-09-22 01:55:02 +02:00
- apt-get update && apt-get install -y curl
2024-09-22 01:54:53 +02:00
- 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
2024-09-22 01:45:32 +02:00
- npm install --global gulp-cli
2024-09-22 01:54:53 +02:00
- gulp --version # Verify Gulp is installed
script:
2024-09-22 01:45:32 +02:00
- npm install
- gulp compile
only:
- branches
2024-09-23 17:58:07 +02:00
artifacts:
paths:
- kidsonbrooms.zip
expire_in: never
2024-09-22 01:45:32 +02:00
# Release Job (manually triggered with version)
release:
stage: release
2024-09-23 17:48:33 +02:00
image: ubuntu:latest
2024-09-22 01:45:32 +02:00
before_script:
2024-09-23 17:58:07 +02:00
# Install necessary tools
- apt-get update && apt-get install -y curl jq git
# Install Node.js v21.x manually
2024-09-22 01:54:53 +02:00
- 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
2024-09-22 01:45:32 +02:00
- npm install --global gulp-cli
2024-09-22 01:54:53 +02:00
- gulp --version # Verify Gulp is installed
2024-09-23 18:09:50 +02:00
- git fetch --all
- git switch master
- git branch --set-upstream-to=origin/master master
2024-09-22 01:45:32 +02:00
script:
# Check if VERSION is provided
2024-09-23 17:58:07 +02:00
- |
if [ -z "$VERSION" ]; then
echo "Error: VERSION variable is required."
exit 1
fi
2024-09-22 01:45:32 +02:00
2024-09-23 17:58:07 +02:00
# Install dependencies and run Gulp release task
2024-09-22 16:56:10 +02:00
- npm install
2024-09-22 01:45:32 +02:00
- gulp release
2024-09-23 18:09:50 +02:00
- grep '"download":' system.json
2024-09-23 17:58:07 +02:00
- git config --global user.name "GitLab CI"
- git config --global user.email "ci@gitlab.com"
2024-09-23 22:35:44 +02:00
- git add kidsonbrooms.zip
- git commit -m "Update .zip with new version"
2024-09-23 18:00:47 +02:00
- git push "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git" HEAD:master
2024-09-22 01:45:32 +02:00
2024-09-23 22:10:05 +02:00
# Create a release on GitLab
- |
export RELEASE_RESPONSE=$(curl --request POST \
--header "PRIVATE-TOKEN: ${GITLAB_PAT}" \
--header "Content-Type: application/json" \
--data '{
"name": "Release v'$VERSION'",
"tag_name": "v'$VERSION'",
"description": "Release v'$VERSION'",
"ref": "master",
"assets": {
"links": [
{
"name": "Download kidsonbrooms.zip",
2024-09-23 22:35:44 +02:00
"url": "https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/kidsonbrooms.zip?inline=false"
2024-09-23 22:10:05 +02:00
}
]
}
}' "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases")
2024-09-22 01:45:32 +02:00
# Publish the release to the Foundry API
2024-09-22 01:48:59 +02:00
- |
curl -X POST https://api.foundryvtt.com/_api/packages/release_version/ \
2024-09-22 01:45:32 +02:00
-H "Authorization: $FOUNDRY_API_KEY" \
-H "Content-Type: application/json" \
2024-09-23 17:58:07 +02:00
-d "{
2024-09-23 22:46:41 +02:00
\"id\": \"kidsonbrooms\",
2024-09-23 17:58:07 +02:00
\"release\": {
\"version\": \"$VERSION\",
2024-09-23 22:42:04 +02:00
\"manifest\": \"https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/system.json\",
2024-09-23 17:58:07 +02:00
\"notes\": \"https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/v$VERSION\",
\"compatibility\": {
2024-09-23 22:53:27 +02:00
\"minimum\": \"12\",
2024-09-23 17:58:07 +02:00
\"verified\": \"12.331\",
\"maximum\": \"\"
2024-09-22 01:45:32 +02:00
}
}
2024-09-23 17:58:07 +02:00
}"
2024-09-22 16:11:43 +02:00
only:
- master
2024-09-22 01:45:32 +02:00
when: manual
allow_failure: false
2024-09-23 17:58:07 +02:00
dependencies:
- compile
2024-09-22 01:45:32 +02:00
artifacts:
paths:
2024-09-22 15:57:37 +02:00
- kidsonbrooms.zip
2024-09-23 17:58:07 +02:00
expire_in: never