Skip to content

Commit

Permalink
release as gpr package (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
beatthat authored Feb 18, 2020
1 parent 6e22256 commit 6540188
Show file tree
Hide file tree
Showing 16 changed files with 3,331 additions and 44 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/gpr-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: publish package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo ${{github.ref}}
- run: export v="${{github.ref}}" && echo "${v##*/}"
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
# - run: npm test
gpr-publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: "@beatthat"
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ sysinfo.txt
node_modules

*.log

package-lock.json
.DS_Store
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=https://npm.pkg.github.com
@beatthat:registry=https://npm.pkg.github.com
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Create a new directory with the same you want to give your package and then exec

```
npm init --force && \
npm install --save beatthat/unity-npm-utils && \
echo "registry=https://npm.pkg.github.com" >> .npmrc && \
npm install --save @beatthat/unity-npm-utils && \
node ./node_modules/unity-npm-utils/bin/unpm upt -v
```

Expand Down
4 changes: 0 additions & 4 deletions lib/unity-package/_install-template-to-tmp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const mkdirp = require('mkdirp')
const path = require('path')
const fs = require('fs-extra')
const request = require('request')
const tmp = require('tmp');
const decompress = require('decompress')
const download = require('download-git-repo')


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,29 @@ const transformPackage = require('../../core/transform-package.js')
* @returns {Promise}
*/
const _setSubProject2PkgDependency = async (pkgRoot, subPkgName, opts) => {

opts = opts || {}


const mainPkg = await readPackage(pkgRoot)
const subPkgRoot = path.join(pkgRoot, subPkgName)

if(!await fs.exists(subPkgRoot)) {
return
}

const subPkg = await transformPackage({
package_path: subPkgRoot,
transform: (subPkg, transformCB) => {
// filter out existing _latest.tgz dependencies (presumably old names for package)
subPkg.dependencies = Object.getOwnPropertyNames(subPkg.dependencies || {}).reduce((cur, acc) => {
subPkg.dependencies = Object.getOwnPropertyNames(subPkg.dependencies || {}).reduce((acc, cur) => {
const v = subPkg.dependencies[cur]
if (!v || typeof v.match === 'function' && v.match(/^.*_latest.tgz$/)) {
if (typeof cur !== 'string' || !v || (typeof v.match === 'function' && v.match(/^.*-latest.tgz$/))) {
return acc
}
acc[cur] = v
return acc
}, {})

subPkg.dependencies[mainPkg.name] = `../${mainPkg.name}-latest.tgz`

subPkg.dependencies['@beatthat/unity-npm-utils'] = '../beatthat-unity-npm-utils.tgz'
transformCB(null, subPkg)
}
})

return subPkg
}

Expand Down
Loading

0 comments on commit 6540188

Please sign in to comment.