Skip to content
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

Add Release action #104

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
44 changes: 40 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
name: 'Publish'

on:
pull_request:
branches:
- main
types: [closed]
workflow_dispatch:
inputs:
version:
description: 'version (without v prefix)'
description: version (without v prefix)
required: true
dry_run:
description: run without publish
type: boolean
default: false

jobs:
publish:
on_release:
if: ${{ github.event.pull_request.merged && contains(github.head_ref, 'release_v_') }}
runs-on: ubuntu-latest
outputs:
SUCCESS: ${{ steps.release.outputs.success }}
steps:
- id: release
run: echo "success=1" >> "$GITHUB_OUTPUT"
on_manual:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.version }}
outputs:
SUCCESS: ${{ steps.manual.outputs.success }}
steps:
- id: manual
run: echo "success=1" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v3
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
Expand All @@ -27,14 +48,29 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- run: yarn version --new-version ${{ github.event.inputs.version }} --no-commit-hooks

- name: Pushing changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
branch: ${{ github.ref }}
publish:
runs-on: ubuntu-latest
if: ${{ needs.on_release.outputs.SUCCESS || needs.on_manual.outputs.SUCCESS }}
needs: [on_release, on_manual]
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
always-auth: true
registry-url: 'https://registry.npmjs.org'

- name: Publushing release
if: ${{ !github.event.inputs.dry_run }}
run: yarn publish --access public --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Release'

on:
pull_request:
workflow_dispatch:
inputs:
release_type:
description: 'Choose release type'
required: true
default: patch
type: choice
options:
- major
- minor
- patch

jobs:
release:
env:
RELEASE_VERSION:
RELEASE_VERSION_REF:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
always-auth: true
registry-url: 'https://registry.npmjs.org'

- name: Calculate release version
env:
RELSEASE_TYPE: ${{ github.event.inputs.release_type }}
run: |
yarn
echo RELEASE_VERSION=$(yarn --silent release_version) >> $GITHUB_ENV
echo RELEASE_VERSION_REF=$(yarn --silent release_version | tr '.' '_') >> $GITHUB_ENV

- name: Bump to release version ${{ env.RELEASE_VERSION }}
run: yarn version --new-version ${{ env.RELEASE_VERSION }} --no-commit-hooks

- name: Create Release Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
commit-message: Release v.${{ env.RELEASE_VERSION }}
committer: GitHub Action <[email protected]>
author: GitHub Action <[email protected]>
branch: release_v_${{ env.RELEASE_VERSION_REF }}
delete-branch: true
base: master
title: Release v${{ env.RELEASE_VERSION }}
Loading