Skip to content

Commit

Permalink
Integrating build:prerelease job for publishing staging NPM packages
Browse files Browse the repository at this point in the history
  • Loading branch information
CMCDragonkai committed May 22, 2022
1 parent 5527ce8 commit daf8abb
Showing 1 changed file with 56 additions and 63 deletions.
119 changes: 56 additions & 63 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,21 @@ 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'
when: manual
- if: $CI_COMMIT_BRANCH == 'master'
when: manual
- when: always

check:nix-dry:
stage: check
needs: []
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'
when: manual
- when: always

check:test:
stage: check
Expand All @@ -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'
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 '
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit daf8abb

Please sign in to comment.