Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
update ts actions (#143)
Browse files Browse the repository at this point in the history
* update ts actions

* update

* update

* update justfile

* revert

* update

* updates

* works on linux

* update

* back to mac

* roll back build.sh
  • Loading branch information
nitro-neal authored Oct 22, 2024
1 parent 6bac761 commit bc45a65
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,11 @@ jobs:
cache: true
- name: Lint
# NOTE: only currently testing nodejs in the CI, not the browser
# The WASM binary is build with a script in npm run build
run: |
cd bound/typescript
npm install
npm run clean
npm run build
npm run test:node:cjs
npm run test:node:esm
npm run test:node:esm
File renamed without changes.
103 changes: 103 additions & 0 deletions .github/workflows/release-typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release TypeScript Package

on:
workflow_dispatch:
inputs:
version:
description: 'Version of the TypeScript package to release and publish to npm. For example "1.0.0" or "1.3.7-beta-2". Required. Must not end in "-SNAPSHOT".'
required: true

jobs:
# Job to set the version and create a git tag
set-version-and-tag:
runs-on: ubuntu-latest
outputs:
RELEASE_TAG: ${{ steps.set-version-and-tag.outputs.RELEASE_TAG }}
RELEASE_VERSION: ${{ steps.set-version-and-tag.outputs.RELEASE_VERSION }}
steps:
# Check out the repository with permissions to push
- uses: actions/checkout@v4
with:
token: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }}

# Set Git configuration for committing
- name: Set Git Config
run: |
git config user.name "tbd-releases"
git config user.email "[email protected]"
# Update version, commit, and tag
- name: Set Version and Tag
id: set-version-and-tag
run: |
version="${{ github.event.inputs.version }}"
if [[ "$version" == *"-SNAPSHOT" ]]; then
echo "Error: The version for release must not end with \"-SNAPSHOT\": $version"
exit 1
fi
cd bound/typescript
npm version "$version" --no-git-tag-version
git add package.json package-lock.json
git commit -m "[TBD Release Manager 🚀] Setting version to: $version"
tagName="ts-v$version"
git tag -a "$tagName" -m "Tag version: $tagName"
echo "RELEASE_TAG=$tagName" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$version" >> $GITHUB_OUTPUT
git push origin "${GITHUB_REF#refs/heads/}"
git push origin "$tagName"
# Job to build, test, and publish the package
build-and-publish:
name: Build and Publish TypeScript Package
needs: set-version-and-tag
runs-on: macos-latest
steps:
# Check out the code at the release tag
- uses: actions/checkout@v4
with:
ref: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }}
token: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }}

# Initialize Hermit environment
- name: Init Hermit
uses: cashapp/activate-hermit@v1
with:
cache: true

# Install dependencies
- name: Install Dependencies
run: |
cd bound/typescript
npm install
# Build the package
- name: Build TypeScript Package
run: |
cd bound/typescript
npm run clean
npm run build
# Run tests
- name: Run Tests
run: |
cd bound/typescript
npm run test:node:cjs
npm run test:node:esm
# Publish to npm
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd bound/typescript
npm publish --access public
# Create a GitHub release
- name: Create GitHub Release
uses: actions/[email protected]
with:
tag_name: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }}
release_name: ${{ needs.set-version-and-tag.outputs.RELEASE_TAG }}
body: "Release of TypeScript package version ${{ needs.set-version-and-tag.outputs.RELEASE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion bound/typescript/bundle-wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ echo "module.exports = \`$(base64 -i pkg/tbdex_wasm_bg.wasm)\`;" > pkg/tbdex_was
mv pkg/tbdex_wasm.js.new pkg/tbdex_wasm.js

# also extend the typescript
cat bundle-wasm/epilogue.d.ts >> pkg/tbdex_wasm.d.ts
cat bundle-wasm/epilogue.d.ts >> pkg/tbdex_wasm.d.ts
9 changes: 8 additions & 1 deletion bound/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tbdex",
"name": "@tbdex/sdk",
"version": "0.1.0",
"type": "module",
"description": "",
Expand All @@ -20,6 +20,13 @@
"require": "./dist/browser.js"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/TBD54566975/tbdex-rs.git"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/chai": "4.3.0",
"@types/mocha": "9.1.0",
Expand Down

0 comments on commit bc45a65

Please sign in to comment.