Skip to content

Commit

Permalink
Publish SDKs and templates via release workflows (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Oct 16, 2024
1 parent 1b06fb5 commit 36e709a
Show file tree
Hide file tree
Showing 33 changed files with 2,030 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-sdk-as-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
node-version: ">=22"
- name: Install source dependencies
working-directory: sdk/assemblyscript/src
run: npm install
run: npm ci
- name: Install example dependencies
run: npm install
run: npm ci
- name: Build project
run: npm run build
6 changes: 3 additions & 3 deletions .github/workflows/ci-sdk-as-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
node-version: ">=22"
- name: Install dependencies
run: npm install
run: npm ci
- name: Check formatting
run: npm run pretty:check
- name: Lint project
Expand All @@ -61,9 +61,9 @@ jobs:
node-version: ">=22"
- name: Install source dependencies
working-directory: sdk/assemblyscript/src
run: npm install
run: npm ci
- name: Install example dependencies
run: npm install
run: npm ci
- name: Check formatting
run: npm run pretty:check
- name: Lint project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-sdk-as-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
with:
node-version: ">=22"
- name: Install dependencies
run: npm install
run: npm ci
- name: Run Unit Tests
run: npm run test
49 changes: 49 additions & 0 deletions .github/workflows/release-sdk-as.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Release AssemblyScript SDK"
on:
push:
tags:
- "sdk/assemblyscript/v*"
permissions:
contents: "write"
id-token: write
jobs:
release:
# note: must use GitHub-hosted runner for publishing to NPM with --provenance flag
runs-on: ubuntu-latest
steps:
- name: "Validate version"
if: ${{ !startsWith(github.ref_name, 'sdk/assemblyscript/v') }}
run: 'echo "Modus AssemblyScript SDK version must start with `sdk/assemblyscript/v` && exit 1'
- uses: actions/checkout@v4
with:
ref: "${{ github.ref_name }}"
- name: Parse SDK Version
id: parse_sdk_version
run: |
echo "sdk_version=$(echo '${{ github.ref_name }}' | cut -d'/' -f 3)" >> $GITHUB_OUTPUT
echo "npm_tag=$(echo '${{ github.ref_name }}' | cut -d'/' -f 3 | sed -E 's/^[^-]+-([a-zA-Z]+).*/\1/ ; s/v.*/latest/')" >> $GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ">=22"
registry-url: "https://registry.npmjs.org"
- name: Prepare Templates
working-directory: sdk/assemblyscript
run: ./scripts/prepare-templates.sh ${{ steps.parse_sdk_version.outputs.sdk_version }}
- name: Set Package Version
working-directory: sdk/assemblyscript/src
run: npm version ${{ steps.parse_sdk_version.outputs.sdk_version }} --no-git-tag-version
- name: Install Dependencies
working-directory: sdk/assemblyscript/src
run: npm ci
- name: Publish NPM Package
working-directory: sdk/assemblyscript/src
run: npm publish --provenance --access public --tag ${{ steps.parse_sdk_version.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: templates_assemblyscript_${{ steps.parse_sdk_version.outputs.sdk_version }}.tar.gz
prerelease: ${{ contains(steps.parse_sdk_version.outputs.sdk_version, '-') }}
make_latest: false
35 changes: 35 additions & 0 deletions .github/workflows/release-sdk-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Release Go SDK"
on:
push:
tags:
- "sdk/go/v*"
permissions:
contents: "write"
jobs:
release:
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: "Validate version"
if: ${{ !startsWith(github.ref_name, 'sdk/go/v') }}
run: 'echo "Modus Go SDK version must start with `sdk/go/v` && exit 1'
- uses: actions/checkout@v4
with:
ref: "${{ github.ref_name }}"
- name: Parse SDK Version
id: parse_sdk_version
run: |
echo "sdk_version=$(echo '${{ github.ref_name }}' | cut -d'/' -f 3)" >> $GITHUB_OUTPUT
- name: Setup Go
uses: actions/setup-go@v5
with:
cache-dependency-path: "./sdk/go/go.sum"
go-version-file: "./sdk/go/go.mod"
- name: Prepare Templates
working-directory: sdk/go
run: ./scripts/prepare-templates.sh ${{ steps.parse_sdk_version.outputs.sdk_version }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: templates_go_${{ steps.parse_sdk_version.outputs.sdk_version }}.tar.gz
prerelease: ${{ contains(steps.parse_sdk_version.outputs.sdk_version, '-') }}
make_latest: false
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ In previous releases, the name "Hypermode" was used for all three._
- Fix entry alignment issue with AssemblyScript maps [#461](https://github.com/hypermodeinc/modus/pull/461)
- Update to use new Modus manifest [#462](https://github.com/hypermodeinc/modus/pull/462)
- Enable GraphQL endpoints to be defined in the manifest [#464](https://github.com/hypermodeinc/modus/pull/464)
- Publish SDKs and templates via release workflows [#465](https://github.com/hypermodeinc/modus/pull/465)

## 2024-10-02 - Version 0.12.7

Expand Down

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/auth/package-lock.json

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

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/collections/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/dgraph/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/embedding/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/graphql/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/http/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/postgresql/package-lock.json

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/simple/package-lock.json

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

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

1 change: 0 additions & 1 deletion sdk/assemblyscript/examples/vectors/package-lock.json

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

42 changes: 42 additions & 0 deletions sdk/assemblyscript/scripts/prepare-templates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Prepares templates for release.

set -euo pipefail
trap "cd \"${PWD}\"" EXIT
cd "$(dirname "$0")"

# get the version number from the command line argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <version>"
exit 1
fi
version=$1

version=${version#"v"}
echo "Preparing templates for release with version ${version}"

cd ../templates
for template in *; do
if [ -d "${template}" ]; then
cd "${template}"

# Remove any output files
rm -rf node_modules
rm -rf build

# Remove the lockfile - it will be regenerated by npm install when the template is used.
rm -f package-lock.json

# Update the version of the modus-sdk-as dependency to match the release version.
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json
else
sed -i 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json
fi

cd ..
fi
done

cd ..
tar -czvf ../../templates_assemblyscript_v${version}.tar.gz templates
1 change: 0 additions & 1 deletion sdk/assemblyscript/src/package-lock.json

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

3 changes: 2 additions & 1 deletion sdk/assemblyscript/src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@hypermode/modus-sdk-as",
"version": "0.13.0-alpha1",
"version": "",
"repository": "github:hypermodeinc/modus",
"description": "Modus SDK for AssemblyScript",
"author": "Hypermode Inc.",
"license": "Apache-2.0",
Expand Down
3 changes: 3 additions & 0 deletions sdk/assemblyscript/templates/default/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["assemblyscript-prettier"]
}
6 changes: 6 additions & 0 deletions sdk/assemblyscript/templates/default/asconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./node_modules/@hypermode/modus-sdk-as/plugin.asconfig.json",
"options": {
"transform": ["@hypermode/modus-sdk-as/transform", "json-as/transform"]
}
}
3 changes: 3 additions & 0 deletions sdk/assemblyscript/templates/default/assembly/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sayHello(name: string | null = null): string {
return `Hello, ${name || "World"}!`;
}
4 changes: 4 additions & 0 deletions sdk/assemblyscript/templates/default/assembly/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "assemblyscript/std/assembly.json",
"include": ["./**/*.ts"]
}
11 changes: 11 additions & 0 deletions sdk/assemblyscript/templates/default/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import aseslint from "@hypermode/modus-sdk-as/tools/assemblyscript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
aseslint.config,
);
10 changes: 10 additions & 0 deletions sdk/assemblyscript/templates/default/modus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://schema.hypermode.com/modus.json",
"endpoints": {
"default": {
"type": "graphql",
"path": "/graphql",
"auth": "bearer-token"
}
}
}
Loading

0 comments on commit 36e709a

Please sign in to comment.