Skip to content

Commit 64dc71c

Browse files
author
Chazal
committed
Add release step
1 parent 8ad0a6a commit 64dc71c

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

.github/workflows/on-release.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: on-release-event
2-
1+
name: release
32
on:
4-
release:
5-
types: [created]
6-
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch: {}
77
jobs:
88
build:
99
runs-on: ubuntu-latest
@@ -18,4 +18,43 @@ jobs:
1818
run: npm run lerna-lint
1919
- name: Run tests
2020
run: npm run lerna-test
21-
# TODO: add publish step
21+
release_github:
22+
name: Publish to GitHub Releases
23+
needs: release
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
if: needs.release.outputs.latest_commit == github.sha
28+
steps:
29+
- name: Download build artifacts
30+
uses: actions/download-artifact@v2
31+
with:
32+
name: dist
33+
path: dist
34+
- name: Release
35+
run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R
36+
$GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt)
37+
--target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode
38+
-ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then
39+
cat $errout; exit $exitcode; fi
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
GITHUB_REPOSITORY: ${{ github.repository }}
43+
GITHUB_REF: ${{ github.ref }}
44+
slack:
45+
name: Publish to slack channel
46+
needs:
47+
- release_npm
48+
- release_pypi
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: publish latest release
52+
env:
53+
SLACK_URL: ${{ secrets.SLACK_URL }}
54+
run: |
55+
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases/latest > release.json
56+
VERSION=$( jq -r '.name' release.json )
57+
CONTENT=$( jq -r '.body' release.json )
58+
jq -n --arg version "$VERSION" --arg content "$CONTENT" '{"release-version": $version, "release-content": $content}' > body.json
59+
curl --location --request POST $SLACK_URL \
60+
--header 'Content-Type: application/json' --data @body.json

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"init-environment": "husky install",
99
"test": "npm run lerna-test",
1010
"commit": "commit",
11+
"package": "npm run package",
1112
"lerna-ci": "lerna exec -- npm ci",
1213
"lerna-test": "lerna exec -- npm run test",
1314
"lerna-build": "lerna exec -- tsc",

packages/logger/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"preversion": "npm run lint",
1919
"version": "npm run format && git add -A src",
2020
"postversion": "git push && git push --tags",
21+
"package": "mkdir -p dist/js && npm pack && mv *.tgz dist/js/",
2122
"example:hello-world": "ts-node examples/hello-world.ts",
2223
"example:inject-context": "ts-node examples/inject-context.ts",
2324
"example:inject-context-decorator": "ts-node examples/inject-context-decorator.ts",

packages/logger/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"baseUrl": "src/",
1616
"rootDirs": [ "src/" ]
1717
},
18-
"include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ],
18+
"include": [ "src/**/*", "examples/**/*" ],
1919
"exclude": [ "./node_modules"],
2020
"watchOptions": {
2121
"watchFile": "useFsEvents",

packages/metrics/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"prepare": "npm run build",
1717
"prepublishOnly": "npm test && npm run lint",
1818
"preversion": "npm run lint",
19+
"package": "mkdir -p dist/js && npm pack && mv *.tgz dist/js/",
1920
"version": "npm run format && git add -A src",
2021
"postversion": "git push && git push --tags",
2122
"example:hello-world": "ts-node examples/hello-world.ts",

0 commit comments

Comments
 (0)