Skip to content

Commit

Permalink
Merge pull request #3 from zMotivat0r/release/release-action
Browse files Browse the repository at this point in the history
ci: updated release action
  • Loading branch information
michaelyali authored Apr 4, 2021
2 parents ac4b6ba + 141b85c commit 25d7309
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 31 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/release-trigger.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

on:
pull_request:
types: [closed]

jobs:
release:
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release')
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set NPM Token
uses: actions/setup-node@v2
with:
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install
run: npm install

- name: Build
run: npm run build

- name: Run tests
run: npm test

- name: Set Current Version
shell: bash -ex {0}
run: |
CURRENT_VERSION=$(cat package.json | npx jase version)
[[ $CURRENT_VERSION =~ "-" ]] && DIST_TAG=$(echo $CURRENT_VERSION | cut -d '-' -f 2 | cut -d '.' -f 1) || DIST_TAG="latest"
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
echo "DIST_TAG=${DIST_TAG}" >> $GITHUB_ENV
- name: Get Latest Git Tag
uses: mukunku/[email protected]
id: checkTag
with:
tag: v${{ env.CURRENT_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Git Tag
if: steps.checkTag.outputs.exists == 'false'
uses: negz/create-tag@v1
with:
version: v${{ env.CURRENT_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
if: steps.checkTag.outputs.exists == 'false'
uses: actions/create-release@v1
with:
tag_name: v${{ env.CURRENT_VERSION }}
release_name: v${{ env.CURRENT_VERSION }}
body: |
${{ github.event.pull_request.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Packages
if: steps.checkTag.outputs.exists == 'false'
run: |
cd ./lib && npm publish --access public --tag ${{ env.DIST_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create a Comment
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Packages with version [v${{ env.CURRENT_VERSION }}](https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }}) have been released 🎉'
})
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## <small>0.1.8 (2021-04-04)</small>

* ci: updated release action ([618119f](https://github.com/zMotivat0r/mrepo/commit/618119f))



## <small>0.1.7 (2021-04-04)</small>

* chore: release 0.1.7 ([ac4b6ba](https://github.com/zMotivat0r/mrepo/commit/ac4b6ba))
* feat: added github templates ([d908cf0](https://github.com/zMotivat0r/mrepo/commit/d908cf0))


Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zmotivat0r/mrepo",
"version": "0.1.7",
"version": "0.1.8",
"main": "index.js",
"types": "index.d.ts",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "monorepo-utils",
"description": "Monorepo utils",
"version": "0.1.7",
"version": "0.1.8",
"private": true,
"scripts": {
"build": "npx tsc -b tsconfig.build.json",
"postbuild": "cpy ./templates/**/* ./lib --parents",
"clean": "npx rimraf \"./lib/!(.npmrc|LICENSE|package.json|README.md)**\"",
"cm": "git-cz",
"commit_": "git-cz",
"lib:link": "cd ./lib && npm link",
"lib:try": "yarn build && yarn lib:unlink && yarn lib:link",
"lib:unlink": "cd ./lib && npm unlink",
Expand Down
2 changes: 0 additions & 2 deletions scripts/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ PACKAGE_VERSION=$(cat package.json | npx jase version)

git add .
git commit -m "chore: release $PACKAGE_VERSION"
git tag v$PACKAGE_VERSION
git push --tags
git push
4 changes: 0 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ npx bump package.json package-lock.json lib/package.json --ignore-scripts

# generate changelog
npx conventional-changelog -i CHANGELOG.md -s -r 0

# save npm release tag in the package.json
[ ! -z "$NPM_TAG" ] && TAG=$NPM_TAG || TAG="latest"
npx json -I -f ./package.json -e "this.config={...this.config, 'releaseTag': '$TAG'}"

0 comments on commit 25d7309

Please sign in to comment.