diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87c4d7fd12c66060921d99588be5996d361b39ea..ae56d01fc6583ab0f32801801904043d8a8b1f7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,5 @@ default: image: node:latest - - # Validate that the repository contains a package.json and extract a few values from it. before_script: - | if [[ ! -f package.json ]]; then @@ -10,24 +8,39 @@ default: fi - echo "current version is :" - echo $(node -p "require('./package.json').version") - stages: - - build - test + - deploy -install: - stage: build +check: + stage: test script: - npm install - npm run build - -check: - stage: test + +publish: + stage: deploy script: + # If no .npmrc if included in the repo, generate a temporary one + - | + if [[ ! -f .npmrc ]]; then + echo 'No .npmrc found! Creating one now. Now we will generate one' + { + echo "//registry.npmjs.org/:_authToken=\${NPM_PUBLISH_TOKEN}" + } >> .npmrc + fi + - echo "Created the following .npmrc:"; cat .npmrc + + # Extract a few values from package.json + - NPM_PACKAGE_NAME=$(node -p "require('./package.json').name") + - NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version") + + # Compare the version in package.json to all published versions. + # If the package.json version has not yet been published, run `npm publish`. - | - if [[ ! -f dist/markdown-editor.js ]]; then - echo "failed!" + if [[ $(npm view "${NPM_PACKAGE_NAME}" versions) != *"'${NPM_PACKAGE_VERSION}'"* ]]; then + npm publish + echo "Successfully published version ${NPM_PACKAGE_VERSION} of ${NPM_PACKAGE_NAME} " + else + echo "Version ${NPM_PACKAGE_VERSION} of ${NPM_PACKAGE_NAME} has already been published, so no new version has been published." fi - - - exit 1 - diff --git a/package.json b/package.json index fe609a6bc0f1e13c18ebbc70d73c84e50c5a25c6..90ca484174dc017df600ee6cc6c475c24a70ec2f 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,22 @@ { - "name": "markdown-editor", - "description": " A open source markdown editor of csdn codechina team contributed", - "version": "0.1.1", - "publisher": "guoweijia", + "name": "cc-md-editor", + "version": "0.1.0", + "description": "A open source markdown editor of csdn codechina", + "main": "main.js", "scripts": { "start": "webpack serve --mode=development", "build": "webpack --mode=production" }, + "repository": { + "type": "git", + "url": "https://codechina.csdn.net/codechina_dev/markdown-editor.git" + }, + "keywords": [ + "markdown", + "editor" + ], + "author": "guoweijia", + "license": "MIT", "devDependencies": { "chalk": "^4.1.1", "css-loader": "^5.2.6",