| 1 | # .gitlab-ci.yml |
| 2 | |
| 3 | # Define stages for the pipeline |
| 4 | stages: |
| 5 | - lint |
| 6 | - build |
| 7 | - release |
| 8 | |
| 9 | verify_code_quality: |
| 10 | stage: lint |
| 11 | image: node:18 # Using an official Node.js Docker image |
| 12 | script: |
| 13 | - npm install -g eslint |
| 14 | - eslint framework/**/*.js --ignore-pattern "framework/extensions/thirdparty.js" --no-warn-ignored |
| 15 | only: |
| 16 | - merge_requests # Run on merge requests |
| 17 | |
| 18 | # Define a job that runs when something is pushed to the master branch |
| 19 | build_job: |
| 20 | stage: build |
| 21 | image: debian:bookworm-slim |
| 22 | script: |
| 23 | - chmod +x ./glbuild.sh # Ensure the script is executable |
| 24 | - ./glbuild.sh # Execute the script |
| 25 | artifacts: |
| 26 | paths: |
| 27 | - js/framework.js |
| 28 | - build_job.env # Ensure the build_job.env file is included in the artifacts |
| 29 | reports: |
| 30 | dotenv: build_job.env |
| 31 | only: |
| 32 | - master # Run this job only when changes are pushed to the master branch |
| 33 | after_script: |
| 34 | # Save the job ID in a .env file to be used by the next job |
| 35 | - echo "BUILD_JOB_ID=$CI_JOB_ID" >> build_job.env |
| 36 | |
| 37 | release_job: |
| 38 | stage: release |
| 39 | image: registry.gitlab.com/gitlab-org/release-cli:latest |
| 40 | dependencies: |
| 41 | - build_job |
| 42 | script: |
| 43 | - echo "running release_job for $TAG" |
| 44 | release: |
| 45 | name: "v0.$CI_PIPELINE_IID" |
| 46 | tag_name: "v0.$CI_PIPELINE_IID" # The version is incremented per pipeline. |
| 47 | description: "v0.$CI_PIPELINE_IID" |
| 48 | ref: "$CI_COMMIT_SHA" # The tag is created from the pipeline SHA. |
| 49 | assets: |
| 50 | links: |
| 51 | - name: "framework.js" |
| 52 | url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/$BUILD_JOB_ID/artifacts/raw/js/framework.js" |
| 53 | only: |
| 54 | - master # Run this job only when changes are pushed to the master branch |
| 55 | before_script: |
| 56 | - source build_job.env |