mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
Npm publish using GitHub actions (#1275)
* chore: bumps verdaccio-htpasswd@2.0.0 * chore: removes circle ci and publish using github-actions * chore: adds bash doctype * chore: adds build and test workflow * chore: fixes coverage error * chore: adds e2e tests * chore: adds headless arg * chore: sets puppeteer in docker env * chore: runs tets through bash * chore: minor fixes
This commit is contained in:
parent
313882ca69
commit
4efbad1ef7
8 changed files with 161 additions and 37 deletions
|
@ -37,13 +37,6 @@ aliases:
|
||||||
- gh-pages
|
- gh-pages
|
||||||
- l10n_master
|
- l10n_master
|
||||||
- /release\/.*/
|
- /release\/.*/
|
||||||
- &execute_on_release
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /v?[0-9]+(\.[0-9]+)+([-+\.][0-9a-zA-Z]+)*/
|
|
||||||
branches:
|
|
||||||
ignore:
|
|
||||||
- /.*/
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare:
|
prepare:
|
||||||
|
@ -53,19 +46,6 @@ jobs:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: *base_config_key
|
key: *base_config_key
|
||||||
- run:
|
|
||||||
name: 'Base environment setup'
|
|
||||||
command: |
|
|
||||||
git config --global user.email "verdacciobot@users.noreply.github.com"
|
|
||||||
git config --global user.name "Verdaccio bot for Deployments"
|
|
||||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
||||||
echo "machine github.com login verdacciobot password $GITHUB_TOKEN" > ~/.netrc
|
|
||||||
- save_cache:
|
|
||||||
key: *base_config_key
|
|
||||||
paths:
|
|
||||||
- ~/.npmrc
|
|
||||||
- ~/.gitconfig
|
|
||||||
- ~/.netrc
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: *yarn_cache_key
|
key: *yarn_cache_key
|
||||||
- run:
|
- run:
|
||||||
|
@ -147,17 +127,6 @@ jobs:
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: coverage/clover.xml
|
path: coverage/clover.xml
|
||||||
|
|
||||||
publish_package:
|
|
||||||
<<: *defaults
|
|
||||||
<<: *default_executor
|
|
||||||
steps:
|
|
||||||
- *restore_repo
|
|
||||||
- restore_cache:
|
|
||||||
key: *base_config_key
|
|
||||||
- run:
|
|
||||||
name: Publish
|
|
||||||
command: scripts/publish.sh
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
workflow:
|
workflow:
|
||||||
|
@ -187,7 +156,3 @@ workflows:
|
||||||
- test_node11
|
- test_node11
|
||||||
- test_e2e
|
- test_e2e
|
||||||
<<: *ignore_non_dev_branches
|
<<: *ignore_non_dev_branches
|
||||||
- publish_package:
|
|
||||||
requires:
|
|
||||||
- coverage
|
|
||||||
<<: *execute_on_release
|
|
||||||
|
|
101
.github/main.workflow
vendored
101
.github/main.workflow
vendored
|
@ -19,3 +19,104 @@ action "Test Publish Verdaccio" {
|
||||||
needs = ["Docker build health check"]
|
needs = ["Docker build health check"]
|
||||||
args = "-d"
|
args = "-d"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workflow "release" {
|
||||||
|
resolves = [
|
||||||
|
"github-release",
|
||||||
|
"release:lint",
|
||||||
|
]
|
||||||
|
on = "push"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:tag-filter" {
|
||||||
|
uses = "actions/bin/filter@master"
|
||||||
|
args = "tag v*"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:install" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["release:tag-filter"]
|
||||||
|
args = "yarn install --frozen-lockfile"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:build" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["release:install"]
|
||||||
|
args = "yarn run code:build"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:lint" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["release:install"]
|
||||||
|
args = "yarn run lint"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:test" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["release:build"]
|
||||||
|
args = "sh scripts/puppeteer-setup-ci.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "release:publish" {
|
||||||
|
needs = ["release:test"]
|
||||||
|
uses = "docker://node:10"
|
||||||
|
args = "sh scripts/publish.sh"
|
||||||
|
secrets = [
|
||||||
|
"REGISTRY_AUTH_TOKEN",
|
||||||
|
]
|
||||||
|
env = {
|
||||||
|
REGISTRY_URL = "registry.npmjs.org"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
action "github-release" {
|
||||||
|
needs = ["release:publish"]
|
||||||
|
uses = "docker://node:10"
|
||||||
|
args = "sh scripts/github-release.sh"
|
||||||
|
secrets = [
|
||||||
|
"GITHUB_TOKEN",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow "build and test" {
|
||||||
|
resolves = [
|
||||||
|
"lint",
|
||||||
|
"coverage",
|
||||||
|
]
|
||||||
|
on = "push"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "branch-filter" {
|
||||||
|
uses = "actions/bin/filter@master"
|
||||||
|
args = "branch"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "install" {
|
||||||
|
needs = ["branch-filter"]
|
||||||
|
uses = "docker://node:10"
|
||||||
|
args = "yarn install --frozen-lockfile"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "build" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["install"]
|
||||||
|
args = "yarn run code:build"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "lint" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["install"]
|
||||||
|
args = "yarn run lint"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "test" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["build"]
|
||||||
|
args = "sh scripts/puppeteer-setup-ci.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "coverage" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
needs = ["test"]
|
||||||
|
args = "yarn run coverage:publish"
|
||||||
|
}
|
10
scripts/github-release.sh
Normal file
10
scripts/github-release.sh
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the last tag from GitHub
|
||||||
|
lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||||
|
|
||||||
|
changelog=$(git show $GITHUB_SHA --unified=0 CHANGELOG.md | tail +12 | sed -e 's/^\+//')
|
||||||
|
|
||||||
|
echo "$changelog"
|
||||||
|
|
||||||
|
echo "$changelog" | node scripts/trigger-release.js $lastTag
|
|
@ -6,5 +6,8 @@ lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||||
# Print it to the console for verification
|
# Print it to the console for verification
|
||||||
echo "Bumping version to new tag: ${lastTag}"
|
echo "Bumping version to new tag: ${lastTag}"
|
||||||
|
|
||||||
|
# creating .npmrc
|
||||||
|
echo "//$REGISTRY_URL/:_authToken=$REGISTRY_AUTH_TOKEN" > .npmrc
|
||||||
|
|
||||||
# Publish to NPM
|
# Publish to NPM
|
||||||
npm publish --tag next --registry https://registry.npmjs.org/
|
npm publish --tag next --registry https://$REGISTRY_URL/
|
||||||
|
|
14
scripts/puppeteer-setup-ci.sh
Normal file
14
scripts/puppeteer-setup-ci.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
|
||||||
|
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
|
||||||
|
# installs, work. https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
|
||||||
|
|
||||||
|
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||||
|
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
|
||||||
|
--no-install-recommends \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& rm -rf /src/*.deb \
|
||||||
|
&& yarn run test:all
|
31
scripts/trigger-release.js
Normal file
31
scripts/trigger-release.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const [, , /* node */ /* file */ tag] = process.argv;
|
||||||
|
|
||||||
|
const getStdin = require('get-stdin');
|
||||||
|
const Octokit = require('@octokit/rest');
|
||||||
|
const octokit = new Octokit({
|
||||||
|
auth: `token ${process.env.GITHUB_TOKEN}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [repoOwner, repoName] = process.env.GITHUB_REPOSITORY.split('/');
|
||||||
|
|
||||||
|
getStdin()
|
||||||
|
.then(changelog =>
|
||||||
|
octokit.repos.createRelease({
|
||||||
|
owner: repoOwner,
|
||||||
|
repo: repoName,
|
||||||
|
tag_name: tag,
|
||||||
|
body: changelog,
|
||||||
|
draft: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.catch(err => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
|
@ -9,7 +9,7 @@ const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
|
||||||
|
|
||||||
module.exports = async function() {
|
module.exports = async function() {
|
||||||
console.log(chalk.green('Setup Puppeteer'));
|
console.log(chalk.green('Setup Puppeteer'));
|
||||||
const browser = await puppeteer.launch({headless: true, /* slowMo: 300 */ });
|
const browser = await puppeteer.launch({ headless: true, /* slowMo: 300 */ args: ['--no-sandbox'] });
|
||||||
global.__BROWSER__ = browser;
|
global.__BROWSER__ = browser;
|
||||||
mkdirp.sync(DIR);
|
mkdirp.sync(DIR);
|
||||||
fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());
|
fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());
|
||||||
|
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue