Skip to content

Commit

Permalink
ci(contracts/core): add release worflows for contracts npm
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhalliday committed Sep 19, 2024
1 parent d9bcc8d commit 0fe7963
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/check-contracts-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check @omni-network/contracts version

on:
push:
tags:
- 'contracts/v*' # Trigger on contracts/v* tags

jobs:
check-version:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Check version
run: |
cd contracts/core
npm_version=$(cat package.json | jq -r '.version')
tag_version=${GITHUB_REF#refs/tags/contracts/v}
echo "npm version: $npm_version"
echo "tag version: $tag_version"
if [ "$npm_version" != "$tag_version" ]; then
echo "Error: package.json version '$npm_version' does not match github tag '$tag_version')"
exit 1
fi
shell: bash
28 changes: 28 additions & 0 deletions .github/workflows/release-contracts-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish @omni-network/contracts to npm

on:
release:
types: [published]

jobs:
publish-release:
# only run for contracts/v* tags
if: startsWith(github.ref, 'refs/tags/contracts/v')
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
- run: |
cd contracts/core
pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions contracts/core/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@omni-network/contracts",
"version": "0.2.0-alpha.6",
"version": "0.2.0-alpha.7",
"license": "GPL-3.0-only",
"packageManager": "pnpm@8.14.0",
"repository": "https://github.com/omni-network/omni/contracts",
"repository": "https://github.com/omni-network/omni/tree/main/contracts/core",
"files": [
"src/**/*.sol",
"test/**/*.sol",
Expand Down

0 comments on commit 0fe7963

Please sign in to comment.