Skip to content

Commit

Permalink
update publish workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Pronin-vk committed May 22, 2024
1 parent 9a8bd6f commit 376e7f8
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 26 deletions.
39 changes: 39 additions & 0 deletions .github/actions/bump-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Workflow / Bump version
description: It bump version of provided package

inputs:
version:
description: <newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease
required: true
npm_tag:
description: tag for NPM artifact
required: false

outputs:
prev_version:
value: ${{ steps.internal_id_prev_version.outputs.value }}
next_version:
value: ${{ steps.internal_id_next_version.outputs.value }}

runs:
using: composite
steps:
- name: Saving current version to env
id: internal_id_prev_version
run: echo "value=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
shell: bash

- name: Bump version
if: ${{ !inputs.npm_tag }}
run: yarn version --new-version "${{ inputs.version }}" --no-commit-hooks
shell: bash

- name: Bump version with npm_tag
if: ${{ inputs.npm_tag }}
run: yarn version --new-version "${{ inputs.version }}" --preid ${{ inputs.npm_tag }} --no-commit-hooks
shell: bash

- name: Saving new version to env
id: internal_id_next_version
run: echo "value=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
shell: bash
48 changes: 48 additions & 0 deletions .github/actions/complete-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Workflow / Complete
description: It finish publishing

inputs:
branch:
description: target branch for git push
required: true
prev_version:
description: package's prev version
required: true
next_version:
description: package's next version
required: true
npm_tag:
description: tag for NPM artifact
required: false
token:
description: token for write access to repository
required: true
npm_token:
description: token for publish package to NPM

runs:
using: composite
steps:
- name: Create tag
run: git tag vk-mini-apps-router@${{ inputs.next_version }}
shell: bash

- name: Pushing changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ inputs.token }}
branch: ${{ inputs.branch }}

- name: Publishing release
if: ${{ !inputs.npm_tag }}
run: yarn publish --access public --non-interactive
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}
shell: bash

- name: Publishing release with npm_tag
if: ${{ inputs.npm_tag }}
run: yarn publish --access public --non-interactive --tag ${{ inputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}
shell: bash
23 changes: 23 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish Workflow / Setup
description: It setting up the repository environment for publish

runs:
using: composite
steps:
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
always-auth: true
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
shell: bash

- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
shell: bash
51 changes: 25 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,41 @@ name: 'Publish'
on:
workflow_dispatch:
inputs:
version:
description: 'version (without v prefix)'
new_version:
description: 'version type:'
type: choice
default: 'minor'
options:
- patch
- minor
- major
required: true

run-name: Publish vk-mini-apps-router ${{ inputs.new_version }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}

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

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Setting up the repository environment
uses: ./.github/actions/setup

- run: yarn version --new-version ${{ github.event.inputs.version }} --no-commit-hooks
- name: Bump version
id: updated_versions_info
uses: ./.github/actions/bump-version
with:
version: ${{ github.event.inputs.new_version }}

- name: Pushing changes
uses: ad-m/github-push-action@master
- name: Complete publish
uses: ./.github/actions/complete-publish
with:
github_token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
branch: ${{ github.ref }}

- name: Publishing release
run: yarn publish --access public --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
prev_version: ${{ steps.updated_versions_info.outputs.prev_version }}
next_version: ${{ steps.updated_versions_info.outputs.next_version }}
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
npm_token: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/publish_prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'Publish (pre-release)'

on:
workflow_dispatch:
inputs:
new_version:
description: 'version type (use prerelease for bumping pre-release version):'
required: true
type: choice
default: 'prerelease'
options:
- prepatch
- preminor
- premajor
- prerelease
npm_tag:
required: true
description: 'NPM tag:'
type: choice
default: 'beta'
options:
- alpha
- beta
- rc
custom_version:
description: 'use syntax x.y.z-beta.0, without "v" (it ignore "version type" parameter):'
required: false

run-name: Publish ${{ inputs.new_version }} vk-mini-apps-router ${{ inputs.custom_version }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}

- name: Setting up the repository environment
uses: ./.github/actions/setup

- name: Bump version
id: updated_versions_info
uses: ./.github/actions/bump-version
with:
version: ${{ github.event.inputs.custom_version || github.event.inputs.new_version }}
npm_tag: ${{ github.event.inputs.npm_tag }}

- name: Complete publish
uses: ./.github/actions/complete-publish
with:
branch: ${{ github.ref }}
prev_version: ${{ steps.updated_versions_info.outputs.prev_version }}
next_version: ${{ steps.updated_versions_info.outputs.next_version }}
npm_tag: ${{ github.event.inputs.npm_tag }}
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
npm_token: ${{ secrets.NPMJS_PUBLISH_TOKEN }}

0 comments on commit 376e7f8

Please sign in to comment.