From 5e2a566e8ef4e4ecb34b1fe7cdca66054fe32160 Mon Sep 17 00:00:00 2001 From: Paul B Date: Tue, 25 May 2021 12:40:03 +0200 Subject: [PATCH] core: add release step in CI to push packed tarballs to GH release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As part of #18 this is a test to try to push tarballs generated by oclif to a Github Release. The idea for the release process would be in two steps: - locally on a developer machine: bump the version, commit, tag and publish to npm with the following command: ``` npm run publish -- 2.0.1 ``` This will not create a github release anymore (due to the added `--no-release-draft` tag passed to `np`). - once the tag is pushed, the CI kicks in with this [github action](https://github.com/softprops/action-gh-release) by doing the following: - Github draft release creation - Upload of standalone tarballs (generated by oclif) - The developer can then edit the newly created draft release to write release notes and publish the release 🚀 --- .github/workflows/release.yml | 62 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f3af4937 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release +on: + workflow_run: + workflows: [ "Developer checks" ] + types: [ completed ] +jobs: + # This 'check_tag' job is a hack because Github doesn't provide the full ref from the + # original triggered workflow. Hopefully in the future we will only have to change + # the condition of the `release` job to: + # + # ${{ github.event.workflow_run.conclusion == 'success' && + # startsWith(github.event.workflow_run, 'refs/tag/v') }} + check_tag: + runs-on: ubuntu-latest + outputs: + run_release: ${{ steps.check-tag.outputs.run_jobs }} + tag: ${{ steps.check-tag.outputs.ref }} + steps: + - name: check reference of dependent workflow ${{ github.event.workflow_run.head_branch }} + id: check-tag + run: | + if [[ ${{ github.event.workflow_run.head_branch }} =~ v[0-9]+\.[0-9]+\.[0-9]+.* ]]; then + echo "::set-output name=run_jobs::true" + echo "::set-output name=ref::${{ github.event.workflow_run.head_branch }}" + else + echo "::set-output name=run_jobs::false" + fi + release: + needs: [check_tag] + if: ${{ github.event.workflow_run.conclusion == 'success' && needs.check_tag.outputs.run_release == 'true' }} + runs-on: ubuntu-latest + strategy: + matrix: + node_version: [ '15' ] + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ needs.check_tag.outputs.tag }} + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: node-${{ matrix.node_version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + node-${{ matrix.node_version }}-build-${{ env.cache-name }}- + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node_version }} + - run: npm ci + - run: npm run pack + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: dist/**/* + draft: true + tag_name: ${{ needs.check_tag.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: bump-sh/cli diff --git a/package.json b/package.json index f2f46379..20a742a0 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "postpack": "rm -f oclif.manifest.json", "prepack": "rm -rf lib && npm run build && oclif-dev manifest && oclif-dev readme", "pretest": "npm run clean && npm run build && npm run lint", - "publish": "np", + "publish": "np --no-release-draft", "test": "mocha \"test/**/*.test.ts\"", "test-coverage": "nyc npm run test", "test-integration": "node ./test/integration.js",