Skip to content

chore(cicd): Add release workflow #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 57 additions & 16 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,62 @@
name: on-release-event

name: release
on:
release:
types: [created]

push:
branches:
- main
workflow_dispatch: {}
jobs:
build:
publish:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Use NodeJS 14"
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install packages
run: |
npm ci
npm run lerna-ci

- name: "Setup npm"
run: |
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"

- name: "Version and publish"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"

if [ ${{ github.base_ref }} = main ]; then
npx lerna version --conventional-commits --create-release github --yes
else
npx lerna version --conventional-commits --conventional-prerelease --preid beta --create-release github --yes
fi

npx lerna publish --no-verify-access from-git --yes

slack:
name: Publish to slack channel
needs:
- publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install packages
- name: publish latest release
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
export NODE_ENV=dev
npm ci
npm run lerna-ci
- name: Run lint
run: npm run lerna-lint
- name: Run tests
run: npm run lerna-test
# TODO: add publish step
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases/latest > release.json
VERSION=$( jq -r '.name' release.json )
CONTENT=$( jq -r '.body' release.json )
jq -n --arg version "$VERSION" --arg content "$CONTENT" '{"release-version": $version, "release-content": $content}' > body.json
curl --location --request POST $SLACK_WEBHOOK_URL \
--header 'Content-Type: application/json' --data @body.json
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"init-environment": "husky install",
"test": "npm run lerna-test",
"commit": "commit",
"package": "npm run package",
"lerna-ci": "lerna exec -- npm ci",
"lerna-test": "lerna exec -- npm run test",
"lerna-package": "lerna exec -- npm run package",
"lerna-build": "lerna exec -- tsc",
"lerna-lint": "lerna exec -- eslint \"./{src,tests}/**/*.ts ./src/*.ts\"",
"lerna-format": "lerna exec -- eslint --fix \"./{src,tests}/**/*.ts ./src/*.ts\"",
Expand Down
1 change: 1 addition & 0 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"preversion": "npm run lint",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags",
"package": "mkdir -p dist/js && npm pack && mv *.tgz dist/js/",
"example:hello-world": "ts-node examples/hello-world.ts",
"example:inject-context": "ts-node examples/inject-context.ts",
"example:inject-context-decorator": "ts-node examples/inject-context-decorator.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('Class: PowertoolLogFormatter', () => {
const formattedTypeError = formatter.formatError(<Error>error);
expect(formattedTypeError).toEqual({
location: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+/),
message: 'Cannot read property \'foo\' of null',
message: expect.stringMatching(/Cannot read propert/),
name: 'TypeError',
stack: expect.stringMatching(/PowertoolLogFormatter.test.ts:[0-9]+:[0-9]+/),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"baseUrl": "src/",
"rootDirs": [ "src/" ]
},
"include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ],
"include": [ "src/**/*", "examples/**/*", "tests/**/*" ],
"exclude": [ "./node_modules"],
"watchOptions": {
"watchFile": "useFsEvents",
Expand Down
1 change: 1 addition & 0 deletions packages/metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"package": "mkdir -p dist/js && npm pack && mv *.tgz dist/js/",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags",
"example:hello-world": "ts-node examples/hello-world.ts",
Expand Down