From 7c67f3e9b66a9d58adf52fc3fec4836d7b768d73 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Wed, 9 Oct 2019 23:25:12 -0400 Subject: [PATCH] Enable GPM (#5660) * Uncomment the deploy_github job for GPR * Automatically add private scope to package for GPM This is requires in order to deploy to GitHub package manager since all packages must be scoped to the organization that they are being deployed to. Because of how publishing scoped packages works with NPM, there is no easier way to rename a package that is being pushed to both a scoped and unscoped registry. * Don't run NPM deploy if it's not a release There was a change last week that now allows jobs to be filtered entirely, so this now works like we had originally hoped. * Tag branch pushes with commit This is needed because you cannot overwrite a version on NPM, so the previous plan of just using the prelease version would only work for a single commit. * Fixed invalid version identifier --- .github/workflows/package-deploy.yml | 57 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/.github/workflows/package-deploy.yml b/.github/workflows/package-deploy.yml index 146c7052..7a42796f 100644 --- a/.github/workflows/package-deploy.yml +++ b/.github/workflows/package-deploy.yml @@ -8,35 +8,37 @@ on: release: ~ jobs: - # deploy_github: - # name: GitHub Package Registry - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v1 - # - name: Use Node.js 8 - # uses: actions/setup-node@v1 - # with: - # node-version: 8 - # registry-url: https://npm.pkg.github.com/ - # scope: '@select2' - # - name: npm install - # run: npm install - # - name: Run linting, tests, minify - # run: grunt - # - name: Deploy (release) - # if: github.event_name == 'release' - # run: npm publish - # env: - # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - # - name: Deploy (release candidate) - # if: github.event_name == 'push' - # run: | - # npm --no-git-tag-version version prerelease - # npm publish --tag next - # env: - # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + deploy_github: + name: GitHub Package Registry + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Use Node.js 8 + uses: actions/setup-node@v1 + with: + node-version: 8 + registry-url: https://npm.pkg.github.com/ + scope: '@select2' + - name: Rename package to include private scope + run: "sed -i -e 's#\"name\": \"select2\"#\"name\": \"@select2/select2\"#' package.json" + - name: npm install + run: npm install + - name: Run linting, tests, minify + run: grunt + - name: Deploy (release) + if: github.event_name == 'release' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Deploy (release candidate) + if: github.event_name == 'push' + run: 'sed -i -E "s/\"version\": \"(.+)\",/\"version\": \"\1-commit-$GITHUB_SHA\",/" package.json && npm publish --tag next' + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + GITHUB_SHA: ${{github.sha}} deploy_npm: name: NPM + if: github.event_name == 'release' runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -51,7 +53,6 @@ jobs: - name: Run linting, tests, minify run: grunt - name: Deploy (release) - if: github.event_name == 'release' run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}