Compare commits

..

6 Commits

Author SHA1 Message Date
Danny McCormick
5273d0df9c Add auth 2019-08-06 18:29:44 -04:00
Danny McCormick
fc9ff49b90 Update version 2019-08-05 22:07:27 -04:00
Danny McCormick
552489ce4b Fix backup downloads 2019-08-05 22:05:24 -04:00
Danny McCormick
401832ee64 Update to 1.0.3 2019-08-05 16:51:20 -04:00
Danny McCormick
b0d4a002ac Update io 2019-08-05 16:49:04 -04:00
Danny McCormick
ea546c14bf Update package version 2019-08-05 15:42:48 -04:00
3 changed files with 27 additions and 7 deletions

View File

@@ -39,21 +39,27 @@ jobs:
- run: npm test - run: npm test
``` ```
Set up auth with npm: Publish to npmjs and GPR with npm:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
version: '10.x' version: '10.x'
registry-url: <registry url> registry-url: 'https://registry.npmjs.org'
- run: npm install - run: npm install
- run: npm publish - run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
Set up auth with yarn: Publish to npmjs and GPR with yarn:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
@@ -66,6 +72,12 @@ steps:
- run: yarn publish - run: yarn publish
env: env:
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
- uses: actions/setup-node@v1
with:
registry-url: 'https://npm.pkg.github.com'
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
# License # License

View File

@@ -30,7 +30,15 @@ function writeRegistryToFile(registryUrl, fileLocation) {
} }
core.debug(`Setting auth in ${fileLocation}`); core.debug(`Setting auth in ${fileLocation}`);
let newContents = ''; let newContents = '';
if (fs.existsSync(fileLocation)) {
const curContents = fs.readFileSync(fileLocation, 'utf8');
curContents.split(os.EOL).forEach((line) => {
// Add current contents unless they are setting the registry
if (!line.toLowerCase().startsWith('registry')) {
newContents += line + os.EOL;
}
});
}
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = scope const registryString = scope

View File

@@ -17,7 +17,7 @@ export function configAuthentication(registryUrl: string) {
} }
function writeRegistryToFile(registryUrl: string, fileLocation: string) { function writeRegistryToFile(registryUrl: string, fileLocation: string) {
let scope = core.getInput('scope'); let scope: string = core.getInput('scope');
if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) {
scope = github.context.repo.owner; scope = github.context.repo.owner;
} }
@@ -37,9 +37,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
}); });
} }
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString = const authString: string =
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = scope const registryString: string = scope
? `${scope}:registry=${registryUrl}` ? `${scope}:registry=${registryUrl}`
: `registry=${registryUrl}`; : `registry=${registryUrl}`;
newContents += `${authString}${os.EOL}${registryString}`; newContents += `${authString}${os.EOL}${registryString}`;