stages: - Build - Upload - Release build: stage: Build tags: # Use a macos runner to build. - darwin before_script: - yarn script: - export VERSION=$(node -e "console.log(require('./package.json').version)") - echo "VERSION=$VERSION" >> variables.env - export APPNAME=$(node -e "console.log(require('./package.json').productName)") - echo "APPNAME=$APPNAME" >> variables.env - yarn build artifacts: reports: dotenv: variables.env name: $CI_COMMIT_REF_SLUG paths: - dist_electron/*.dmg - dist_electron/*.zip - dist_electron/*.yml when: on_success only: - main variables: PACKAGE: '${APPNAME}-${VERSION}.dmg' PACKAGE_REGISTRY_URL: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${APPNAME}/${VERSION}' # Upload package to gitlab registry. upload: stage: Upload needs: - job: build artifacts: true rules: - if: $CI_COMMIT_TAG when: never # Do not run this job when a tag is created manually - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when when commits are pushed to the default branch script: # Take the package we built and place it in the package registry. - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist_electron/${PACKAGE}" "${PACKAGE_REGISTRY_URL}/${PACKAGE}"' auto-release-master: image: registry.gitlab.com/gitlab-org/release-cli needs: - job: build artifacts: true - job: upload artifacts: true stage: Release rules: - if: $CI_COMMIT_TAG when: never # Do not run this job when a tag is created manually - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when when commits are pushed to the default branch script: - echo "Release $VERSION" - release-cli create --name "Release $VERSION" --tag-name v$VERSION --description "Release $CI_COMMIT_TITLE" --ref $CI_COMMIT_SHA --assets-link "{\"name\":\"${APPNAME}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${PACKAGE}\"}"