Skip to content

Commit

Permalink
Merge pull request #94 from lindsaymoralesb/devops/github-actions
Browse files Browse the repository at this point in the history
DevOps: GitHub Actions
  • Loading branch information
clexmond authored Jul 1, 2024
2 parents 6c70f9e + ea5873a commit 4fcf6ed
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/beta-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build beta version

on:
push:
branches:
-master

jobs:
create-beta-version:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Increment Beta Version
run: |
VERSION=$(node -p "require('./package.json').version")
BASE_VERSION=$(echo $VERSION | sed 's/-beta\.[0-9]*//')
BETA_NUMBER=$(echo $VERSION | sed -n 's/.*-beta\.\([0-9]*\)/\1/p')
NEW_BETA_NUMBER=$((BETA_NUMBER + 1))
NEW_VERSION="$BASE_VERSION-beta.$NEW_BETA_NUMBER"
npm version $NEW_VERSION --no-git-tag-version
echo "New version: $NEW_VERSION"
- name: Commit and push changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add package.json
git commit -m "Create beta version $NEW_VERSION"
git push
35 changes: 35 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Publish SDK

on:
release:
types:
- published

jobs:
build-and-publish:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Build SDK
run: npm run build

- name: Publish SDK to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: npm run publish-sdk
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"export-production-chains": "node ./src/scripts/exportProductionChains.js",
"lint": "eslint ./src",
"prepublishOnly": "npm run build",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --recursive"
"test": "NODE_ENV=test ./node_modules/.bin/mocha --recursive",
"publish-sdk": "npm run build && npm publish --access public"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 4fcf6ed

Please sign in to comment.