image: node:lts variables: PACKAGE_NAME: foundry-factory-demo-gitlab PACKAGE_TYPE: module PACKAGE_REGISTRY_URL: $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/$PACKAGE_NAME stages: - build - prepare-release - release - publish cache: &global_cache paths: - .npm lint: stage: build before_script: - npm ci --cache .npm --prefer-offline script: - npm run lint cache: <<: *global_cache test: stage: build before_script: - npm ci --cache .npm --prefer-offline script: - npm run test:ci cache: <<: *global_cache artifacts: when: always reports: junit: - junit.xml typecheck: stage: build before_script: - npm ci --cache .npm --prefer-offline script: - npm run typecheck cache: <<: *global_cache build: stage: build before_script: - apt --yes update - apt --yes install jq - npm ci --cache .npm --prefer-offline script: | jq '.version = $version | .url = $url | .manifest = $manifest | .download = $download' \ --arg version "${CI_COMMIT_TAG:1}" \ --arg url "$CI_PROJECT_URL" \ --arg manifest "$PACKAGE_REGISTRY_URL/latest/$PACKAGE_TYPE.json" \ --arg download "$CI_PROJECT_URL/-/releases/$CI_COMMIT_TAG/downloads/$PACKAGE_TYPE.zip" \ src/$PACKAGE_TYPE.json > src/tmp.$$.json mv src/tmp.$$.json src/$PACKAGE_TYPE.json npm run build cache: <<: *global_cache artifacts: paths: - dist expire_in: 1 week publish-artifacts: stage: prepare-release image: alpine:latest before_script: - apk update - apk add zip curl script: | cd dist zip -r ../$PACKAGE_TYPE.zip . cd .. curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file $PACKAGE_TYPE.zip "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.zip" curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/$PACKAGE_TYPE.json "$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.json" rules: - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/' release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest script: - echo 'release job' rules: - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/' release: name: ${CI_COMMIT_TAG:1} tag_name: $CI_COMMIT_TAG description: '**Installation:** To manually install this release, please use the following manifest URL: $CI_PROJECT_URL/-/releases/$CI_COMMIT_TAG/downloads/$PACKAGE_TYPE.json' assets: links: - name: '$PACKAGE_TYPE.zip' url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.zip' filepath: /$PACKAGE_TYPE.zip link_type: package - name: '$PACKAGE_TYPE.json' url: '$PACKAGE_REGISTRY_URL/$CI_COMMIT_TAG/$PACKAGE_TYPE.json' filepath: /$PACKAGE_TYPE.json link_type: other publish-latest-manifest: stage: publish image: alpine:latest before_script: - apk update - apk add zip curl script: | curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/$PACKAGE_TYPE.json "$PACKAGE_REGISTRY_URL/latest/$PACKAGE_TYPE.json" rules: - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'