| 1 | # .gitlab-ci.yml |
| 2 | |
| 3 | # Define stages for the pipeline |
| 4 | stages: |
| 5 | - build |
| 6 | - release |
| 7 | |
| 8 | # Define a job that runs when something is pushed to the master branch |
| 9 | build_job: |
| 10 | stage: build |
| 11 | script: |
| 12 | - apt-get update -qy |
| 13 | - chmod +x ./glbuild.sh # Ensure the script is executable |
| 14 | - ./glbuild.sh # Execute the script |
| 15 | artifacts: |
| 16 | paths: |
| 17 | - js/framework.js |
| 18 | - build_job.env # Ensure the build_job.env file is included in the artifacts |
| 19 | reports: |
| 20 | dotenv: build_job.env |
| 21 | only: |
| 22 | - master # Run this job only when changes are pushed to the master branch |
| 23 | after_script: |
| 24 | # Save the job ID in a .env file to be used by the next job |
| 25 | - echo "BUILD_JOB_ID=$CI_JOB_ID" >> build_job.env |
| 26 | |
| 27 | release_job: |
| 28 | stage: release |
| 29 | image: registry.gitlab.com/gitlab-org/release-cli:latest |
| 30 | dependencies: |
| 31 | - build_job |
| 32 | script: |
| 33 | - echo "running release_job for $TAG" |
| 34 | release: |
| 35 | name: 'v0.$CI_PIPELINE_IID' |
| 36 | tag_name: 'v0.$CI_PIPELINE_IID' # The version is incremented per pipeline. |
| 37 | description: 'v0.$CI_PIPELINE_IID' |
| 38 | ref: '$CI_COMMIT_SHA' # The tag is created from the pipeline SHA. |
| 39 | assets: |
| 40 | links: |
| 41 | - name: 'framework.js' |
| 42 | url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/$BUILD_JOB_ID/artifacts/file/js/framework.js" |
| 43 | only: |
| 44 | - master # Run this job only when changes are pushed to the master branch |
| 45 | before_script: |
| 46 | - source build_job.env |