feat: ci/cd
This commit is contained in:
parent
b5f97a31e4
commit
7fc334ab80
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
# Node Modules
|
||||||
|
node_modules/
|
||||||
|
module/foundry.js
|
||||||
|
foundry.js
|
||||||
|
foundry_07.js
|
||||||
|
package-lock.json
|
94
.gitlab-ci.yml
Normal file
94
.gitlab-ci.yml
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
stages:
|
||||||
|
- compile
|
||||||
|
- release
|
||||||
|
|
||||||
|
# Compile Job (runs on every commit)
|
||||||
|
compile:
|
||||||
|
stage: compile
|
||||||
|
image: node:14
|
||||||
|
script:
|
||||||
|
- npm install --global gulp-cli
|
||||||
|
- npm install
|
||||||
|
- gulp compile
|
||||||
|
only:
|
||||||
|
- branches
|
||||||
|
|
||||||
|
# Release Job (manually triggered with version)
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
image: node:14
|
||||||
|
before_script:
|
||||||
|
- apt-get update && apt-get install -y curl jq
|
||||||
|
- npm install --global gulp-cli
|
||||||
|
- npm install
|
||||||
|
# Set up SSH agent and add private key for pushing to protected branch
|
||||||
|
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- chmod 700 ~/.ssh
|
||||||
|
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
|
||||||
|
script:
|
||||||
|
# Check if VERSION is provided
|
||||||
|
- if [ -z "$VERSION" ]; then echo "Error: VERSION variable is required." && exit 1; fi
|
||||||
|
|
||||||
|
# Run Gulp release task (includes zipping)
|
||||||
|
- gulp release
|
||||||
|
|
||||||
|
# Create a release on GitLab
|
||||||
|
- export RELEASE_RESPONSE=$(curl --request POST \
|
||||||
|
--header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--data '{
|
||||||
|
"name": "Release v'$VERSION'",
|
||||||
|
"tag_name": "v'$VERSION'",
|
||||||
|
"description": "Release v'$VERSION'",
|
||||||
|
"ref": "master",
|
||||||
|
"assets": {
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"name": "Download kids-on-brooms.zip",
|
||||||
|
"url": "https://gitlab.com/YOUR_NAMESPACE/YOUR_PROJECT/-/jobs/$CI_JOB_ID/artifacts/download"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}' "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases")
|
||||||
|
|
||||||
|
# Get the release URL from the response
|
||||||
|
- export RELEASE_URL=$(echo $RELEASE_RESPONSE | jq -r '.assets.links[0].url')
|
||||||
|
|
||||||
|
# Update the system.json file with the release URL
|
||||||
|
- sed -i "s|\"download\":.*|\"download\": \"$RELEASE_URL\",|" system.json
|
||||||
|
|
||||||
|
# Commit the updated system.json and push it to master
|
||||||
|
- 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 origin 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/wintermyst/kids-on-brooms/-/raw/master/system.json",
|
||||||
|
"notes": "https://gitlab.com/wintermyst/kids-on-brooms/releases/tag/v'$VERSION'",
|
||||||
|
"compatibility": {
|
||||||
|
"minimum": "12.331",
|
||||||
|
"verified": "12.331",
|
||||||
|
"maximum": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
when: manual
|
||||||
|
allow_failure: false
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- kids-on-brooms.zip
|
||||||
|
expire_in: never
|
10
.npmignore
Normal file
10
.npmignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
# Node Modules
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
|
||||||
|
# Foundry
|
||||||
|
*.lock
|
Loading…
Reference in New Issue
Block a user