diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cca372d..f9fd33b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,11 +48,10 @@ check:lint: npm run lint; ' rules: - - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - when: always check:nix-dry: stage: check @@ -60,11 +59,10 @@ check:nix-dry: script: - nix-build -v -v --dry-run ./release.nix rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ when: manual - - when: always check:test: stage: check @@ -81,19 +79,15 @@ check:test: junit: - ./tmp/junit.xml rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_BRANCH != 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ when: manual - # This job will be overridden by `build:linux` - - if: $CI_COMMIT_BRANCH == 'staging' - when: never - - when: always build:linux: stage: build needs: - - check:lint + - job: check:lint + optional: true script: - > nix-shell --run ' @@ -107,17 +101,17 @@ build:linux: - ./tmp/junit.xml paths: - ./prebuilds/ + # Only the build:linux preserves the dist + - ./dist rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ build:windows: stage: build needs: - - check:lint + - job: check:lint + optional: true tags: - windows before_script: @@ -138,16 +132,14 @@ build:windows: paths: - ./prebuilds/ rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ build:macos: stage: build needs: - - check:lint + - job: check:lint + optional: true tags: - shared-macos-amd64 image: macos-11-xcode-12 @@ -174,11 +166,30 @@ build:macos: paths: - ./prebuilds/ rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + +build:prerelease: + stage: build + needs: + - build:linux + - build:windows + - build:macos + # Don't interrupt publishing job + interruptible: false + allow_failure: true + before_script: + - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc + script: + - > + nix-shell --run ' + npm publish --tag prerelease --access public; + ' + after_script: + - rm -f ./.npmrc + rules: + # Only prerelease tag + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/ integration:builds: stage: integration @@ -213,11 +224,8 @@ integration:builds: paths: - ./builds/ rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ integration:nix: stage: integration @@ -232,11 +240,8 @@ integration:nix: )" - $build_application/bin/typescript-demo-lib rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ integration:docker: stage: integration @@ -253,11 +258,8 @@ integration:docker: - image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)" - docker run "$image" rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ integration:linux: stage: integration @@ -267,11 +269,8 @@ integration:linux: script: - for f in ./builds/*-linux-*; do "$f"; done rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ integration:windows: stage: integration @@ -282,11 +281,8 @@ integration:windows: script: - Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName} rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ integration:macos: stage: integration @@ -298,11 +294,8 @@ integration:macos: script: - for f in ./builds/*-macos-x64*; do "$f"; done rules: - - if: $CI_COMMIT_TAG - when: manual - - if: $CI_COMMIT_BRANCH == 'master' - when: manual - - if: $CI_COMMIT_BRANCH == 'staging' + - if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ # packages: # stage: release