Skip to content

Commit ffa1c9f

Browse files
committed
core: add release step in CI to push packed tarballs to GH release
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 🚀
1 parent fe8c7f5 commit ffa1c9f

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

.github/workflows/release.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
on:
3+
workflow_run:
4+
workflows: [ "Developer checks" ]
5+
types: [ completed ]
6+
jobs:
7+
# This 'check_tag' job is a hack because Github doesn't provide the full ref from the
8+
# original triggered workflow. Hopefully in the future we will only have to change
9+
# the condition of the `release` job to:
10+
#
11+
# ${{ github.event.workflow_run.conclusion == 'success' &&
12+
# startsWith(github.event.workflow_run, 'refs/tag/v') }}
13+
check_tag:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
run_release: ${{ steps.check-tag.outputs.run_jobs }}
17+
steps:
18+
- name: check reference of dependent workflow ${{ github.event.workflow_run.head_branch }}
19+
id: check-tag
20+
run: |
21+
if [[ ${{ github.event.workflow_run.head_branch }} =~ v[0-9]+\.[0-9]+\.[0-9]+.* ]]; then
22+
echo "::set-output name=run_jobs::true"
23+
else
24+
echo "::set-output name=run_jobs::false"
25+
fi
26+
release:
27+
needs: [check_tag]
28+
if: ${{ github.event.workflow_run.conclusion == 'success' && needs.check_tag.outputs.run_release == 'true' }}
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
node_version: [ '15' ]
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Cache node modules
36+
uses: actions/cache@v2
37+
env:
38+
cache-name: cache-node-modules
39+
with:
40+
# npm cache files are stored in `~/.npm` on Linux/macOS
41+
path: ~/.npm
42+
key: node-${{ matrix.node_version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
43+
restore-keys: |
44+
node-${{ matrix.node_version }}-build-${{ env.cache-name }}-
45+
- uses: actions/setup-node@v2
46+
with:
47+
node-version: ${{ matrix.node_version }}
48+
- run: npm ci
49+
- run: npm run pack
50+
- name: Release
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
files: dist/**/*
54+
draft: true
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
GITHUB_REPOSITORY: paulrbr/bump-node-cli

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"postpack": "rm -f oclif.manifest.json",
6969
"prepack": "rm -rf lib && npm run build && oclif-dev manifest && oclif-dev readme",
7070
"pretest": "npm run clean && npm run build && npm run lint",
71-
"publish": "np",
71+
"publish": "np --no-release-draft",
7272
"test": "mocha \"test/**/*.test.ts\"",
7373
"test-coverage": "nyc npm run test",
7474
"test-integration": "node ./test/integration.js",

0 commit comments

Comments
 (0)