diff --git a/.gitignore b/.gitignore index e91237ad7..cb73be599 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,7 @@ tunnel.log /.well-known-cache /**/tmp-* /testdata/bigAlloc_*.csv -/sessions \ No newline at end of file +/sessions +/changelog.json +/.current-version +/.current-changelog.md \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0a958a90..ee695de0e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,7 @@ variables: UPLOAD_S3_KEY_ID: gOel7KvadwNKgjjy UPLOAD_S3_KEY: ugO5pkEla7F0JW9MdPwLi4MWLT5ZbqAL N_PREFIX: "${HOME}/.n" + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/uni2work" stages: - setup @@ -34,6 +35,9 @@ stages: - yesod:build - lint - test + - prepare release + - upload packages + - release # - deploy npm install: @@ -207,6 +211,81 @@ frontend:test: retry: 2 interruptible: true +parse-changelog: + cache: {} + stage: prepare release + dependencies: + - npm install + needs: + - npm install + before_script: + - rm -rvf /etc/apt/sources.list /etc/apt/sources.list.d + - install -v -T -m 0644 ${APT_SOURCES_LIST} /etc/apt/sources.list + - apt-get update -y + - apt-get install -y --no-install-recommends jq + script: + - npm run parse-changelog + - | + jq -r '.versions[0].version' changelog.json > .current-version + - | + jq -r '.versions[0].body' changelog.json > .current-changelog.md + artifacts: + paths: + - .current-version + - .current-changelog.md + name: "changelog-${CI_COMMIT_SHORT_SHA}" + expire_in: "1 day" + retry: 2 + interruptable: true + +upload: + cache: {} + stage: upload packages + image: curlimages/curl:latest + needs: + - yesod:build + - parse-changelog + dependencies: + - yesod:build + - parse-changelog + rules: + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9].*/ + when: always + before_script: + - export VERSION="$(cat .current-version)" + script: + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/uniworx ${PACKAGE_REGISTRY_URL}/${VERSION}/uniworx + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/uniworxdb ${PACKAGE_REGISTRY_URL}/${VERSION}/uniworxdb + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/uniworxload ${PACKAGE_REGISTRY_URL}/${VERSION}/uniworxload + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/uniworx-wflint ${PACKAGE_REGISTRY_URL}/${VERSION}/uniworx-wflint + +release: + cache: {} + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: + - upload + - parse-changelog + dependencies: + - parse-changelog + rules: + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9].*/ + when: always + before_script: + - export VERSION="$(cat .current-version)" + script: + - | + release-cli create --name "${VERSION}" --tag-name $CI_COMMIT_TAG --description ./current-changelog.md \ + --assets-link "{\"name\":\"uniworx\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/uniworx\",\"filepath\":\"uniworx\"}" \ + --assets-link "{\"name\":\"uniworxdb\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/uniworxdb\",\"filepath\":\"uniworxdb\"}" \ + --assets-link "{\"name\":\"uniworxload\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/uniworxload\",\"filepath\":\"uniworxload\"}" \ + --assets-link "{\"name\":\"uniworx-wflint\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/uniworx-wflint\",\"filepath\":\"uniworx-wflint\"}" + + # deploy:uniworx3: # cache: {} # stage: deploy diff --git a/package-lock.json b/package-lock.json index 184f1dd75..defd89e5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5115,6 +5115,16 @@ "supports-color": "^5.3.0" } }, + "changelog-parser": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/changelog-parser/-/changelog-parser-2.8.0.tgz", + "integrity": "sha512-ZtSwN0hY7t+WpvaXqqXz98RHCNhWX9HsvCRAv1aBLlqJ7BpKtqdM6Nu6JOiUhRAWR7Gov0aN0fUnmflTz0WgZg==", + "dev": true, + "requires": { + "line-reader": "^0.2.4", + "remove-markdown": "^0.2.2" + } + }, "chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", @@ -11247,6 +11257,12 @@ "type-check": "~0.3.2" } }, + "line-reader": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/line-reader/-/line-reader-0.2.4.tgz", + "integrity": "sha1-xDkrWH3qOFgMlnhXDm6OSfzlJiI=", + "dev": true + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -18054,6 +18070,12 @@ "trash": "6.1.1" } }, + "remove-markdown": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.2.2.tgz", + "integrity": "sha1-ZrDO66n7d8qWNrsbAwfOIaMqEqY=", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", diff --git a/package.json b/package.json index a8b986ab7..a92fbe4fd 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "i18n:test": "./missing-translations.sh", "prerelease": "./is-clean.sh && npm run test", "release": "standard-version -a", - "postrelease": "git push --follow-tags origin master" + "postrelease": "git push --follow-tags origin master", + "parse-changelog": "changelog-parser ./CHANGELOG.md > changelog.json" }, "husky": { "hooks": { @@ -70,6 +71,7 @@ "babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-preset-es2015": "^6.24.1", "cbt_tunnels": "^1.2.2", + "changelog-parser": "^2.8.0", "clean-webpack-plugin": "^3.0.0", "copy-webpack-plugin": "^6.0.3", "css-loader": "^2.1.1", @@ -109,8 +111,8 @@ "terser-webpack-plugin": "^2.3.8", "tmp": "^0.1.0", "typeface-roboto": "0.0.75", - "typeface-source-sans-pro": "0.0.75", "typeface-source-code-pro": "^1.1.3", + "typeface-source-sans-pro": "0.0.75", "webpack": "^4.44.1", "webpack-cli": "^3.3.12", "webpack-manifest-plugin": "^2.2.0",