Skip to content

Commit

Permalink
Add logic to do automated github releases
Browse files Browse the repository at this point in the history
  • Loading branch information
drohit-cb committed May 2, 2024
1 parent fc03ea1 commit ead56eb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
57 changes: 45 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
name: Version 🔖

on:
release:
types: [created]
push:
# disabled for testing
# branches:
# - main
paths:
- 'package.json'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
version:
name: Release
release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
- name: Checkout code
uses: actions/checkout@v4

- name: Get version from package.json
id: package_version
run: echo "::set-output name=VERSION::$(node -p "require('./package.json').version")"

- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
if git rev-parse "v${{ steps.package_version.outputs.VERSION }}" >/dev/null 2>&1; then
echo "::set-output name=EXISTS::true"
fi
- name: Create Release
if: steps.check_tag.outputs.EXISTS != 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package_version.outputs.VERSION }}
release_name: Release v${{ steps.package_version.outputs.VERSION }}
draft: false
prerelease: false

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm install -g npm@^9.5.0
- run: npm ci
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to NPM
run: |
npm install -g npm@^9.5.0
npm ci
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/staking-client-library-ts",
"version": "0.6.0",
"version": "0.7.0",
"description": "Coinbase Staking API Typescript Library",
"repository": "https://github.com/coinbase/staking-client-library-ts.git",
"license": "Apache-2.0",
Expand Down

0 comments on commit ead56eb

Please sign in to comment.