Updated release workflow
This commit is contained in:
130
.gitlab-ci.yml
130
.gitlab-ci.yml
@ -1,11 +1,24 @@
|
||||
image: ubuntu:latest
|
||||
|
||||
|
||||
stages:
|
||||
- compile
|
||||
- build
|
||||
- release
|
||||
|
||||
# Compile Job (runs on every commit)
|
||||
compile:
|
||||
stage: compile
|
||||
image: ubuntu:latest
|
||||
variables:
|
||||
MANIFEST: "system.json"
|
||||
ZIPFILE: "kidsonbrooms.zip"
|
||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}"
|
||||
MANIFEST_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${MANIFEST}"
|
||||
ZIPFILE_RELEASE_URL: "${PACKAGE_REGISTRY_URL}/${ZIPFILE}"
|
||||
MANIFEST_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/permalink/latest/downloads/${MANIFEST}"
|
||||
ZIPFILE_PERMALINK_URL: "https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/${CI_COMMIT_TAG}/downloads/${ZIPFILE}"
|
||||
dry_run: true
|
||||
|
||||
|
||||
# Build job
|
||||
build:
|
||||
stage: build
|
||||
before_script:
|
||||
# Install Node.js v21.x manually
|
||||
- apt-get update && apt-get install -y curl
|
||||
@ -17,94 +30,57 @@ compile:
|
||||
- gulp --version # Verify Gulp is installed
|
||||
script:
|
||||
- npm install
|
||||
- gulp compile
|
||||
only:
|
||||
- branches
|
||||
- gulp build
|
||||
artifacts:
|
||||
paths:
|
||||
- kidsonbrooms.zip
|
||||
expire_in: never
|
||||
- system.json
|
||||
- packs/
|
||||
only:
|
||||
- branches
|
||||
|
||||
# Release Job (manually triggered with version)
|
||||
# Release job
|
||||
release:
|
||||
stage: release
|
||||
image: ubuntu:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
before_script:
|
||||
# Install necessary tools
|
||||
- apt-get update && apt-get install -y curl jq git
|
||||
# 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
|
||||
- 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
|
||||
only:
|
||||
- tags
|
||||
|
||||
- grep '"download":' system.json
|
||||
- git config --global user.name "GitLab CI"
|
||||
- git config --global user.email "ci@gitlab.com"
|
||||
- git add kidsonbrooms.zip
|
||||
- git commit -m "Update .zip with new version"
|
||||
- git push "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git" HEAD:master
|
||||
# Create GitLab release
|
||||
create-release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
variables:
|
||||
dry_run: "false"
|
||||
needs:
|
||||
- job: release
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- echo "Creating GitLab release for $CI_COMMIT_TAG"
|
||||
release:
|
||||
name: "$CI_COMMIT_TAG"
|
||||
tag_name: "$CI_COMMIT_TAG"
|
||||
description: "Release $CI_COMMIT_TAG of $CI_PROJECT_NAME."
|
||||
assets:
|
||||
links:
|
||||
- name: "$MANIFEST"
|
||||
url: "${MANIFEST_RELEASE_URL}"
|
||||
filepath: "/${MANIFEST}"
|
||||
- name: "$ZIPFILE"
|
||||
url: "${ZIPFILE_PERMALINK_URL}"
|
||||
filepath: "/${ZIPFILE}"
|
||||
|
||||
# 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",
|
||||
"url": "https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/kidsonbrooms.zip?inline=false"
|
||||
}
|
||||
]
|
||||
}
|
||||
}' "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/releases")
|
||||
# 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\": \"kidsonbrooms\",
|
||||
\"release\": {
|
||||
\"version\": \"$VERSION\",
|
||||
\"manifest\": \"https://gitlab.com/wintermyst/kidsonbrooms/-/raw/master/system.json\",
|
||||
\"notes\": \"https://gitlab.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/-/releases/v$VERSION\",
|
||||
\"compatibility\": {
|
||||
\"minimum\": \"12\",
|
||||
\"verified\": \"12.331\",
|
||||
\"maximum\": \"\"
|
||||
}
|
||||
}
|
||||
}"
|
||||
only:
|
||||
- master
|
||||
when: manual
|
||||
allow_failure: false
|
||||
dependencies:
|
||||
- compile
|
||||
artifacts:
|
||||
paths:
|
||||
- kidsonbrooms.zip
|
||||
expire_in: never
|
||||
|
Reference in New Issue
Block a user