Skip to content

Commit

Permalink
Automatically generate and push releases info to R2 bucket on every r…
Browse files Browse the repository at this point in the history
…elease (#526)
  • Loading branch information
kevinmingtarja authored Nov 4, 2024
1 parent 32014d7 commit f8657fb
Show file tree
Hide file tree
Showing 17 changed files with 2,068 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci-release-info-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci-release-info-build
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- 'tools/release-info/**'
jobs:
build:
if: github.event_name == 'pull_request'
name: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools/release-info
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ">=22"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
31 changes: 31 additions & 0 deletions .github/workflows/ci-release-info-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ci-release-info-lint
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- 'tools/release-info/**'
jobs:
lint:
if: github.event_name == 'pull_request'
name: lint (tools/release-info)
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools/release-info
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ">=22"
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run pretty:check
- name: Lint
run: npm run lint
5 changes: 5 additions & 0 deletions .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:

jobs:
release:
name: Release
# note: must use GitHub-hosted runner for publishing to NPM with --provenance flag
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -49,3 +50,7 @@ jobs:
with:
prerelease: ${{ contains(steps.parse_cli_version.outputs.cli_version, '-') }}
make_latest: false
release-info:
needs: release
name: Generate Release Info
uses: ./.github/workflows/release-info.yaml
44 changes: 44 additions & 0 deletions .github/workflows/release-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Generate Release Info
on:
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
release-info:
runs-on: warp-ubuntu-latest-x64-2x
steps:
- uses: actions/checkout@v4
with:
ref: "${{ github.ref_name }}"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ">=22"
registry-url: "https://registry.npmjs.org"
- name: Install Dependencies
working-directory: tools/release-info
run: npm ci
- name: Build
working-directory: tools/release-info
run: npm run build
- name: Run
working-directory: tools/release-info
run: node dist/index.js
- name: Push to R2 Bucket
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_TOKEN }}
wranglerVersion: "3.83.0"
workingDirectory: "tools/release-info"
preCommands: |
cat modus-latest.json
cat modus-preview.json
cat modus-all.json
cat modus-preview-all.json
command: |
r2 object put releases/modus-latest.json -f modus-latest.json --content-type application/json
r2 object put releases/modus-preview.json -f modus-preview.json --content-type application/json
r2 object put releases/modus-all.json -f modus-all.json --content-type application/json
r2 object put releases/modus-preview-all.json -f modus-preview-all.json --content-type application/json
5 changes: 5 additions & 0 deletions .github/workflows/release-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
release:
name: Release
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: Validate version
Expand Down Expand Up @@ -37,3 +38,7 @@ jobs:
MACOS_NOTARY_ISSUER_ID: "${{ secrets.MACOS_NOTARY_ISSUER_ID }}"
MACOS_NOTARY_KEY_ID: "${{ secrets.MACOS_NOTARY_KEY_ID }}"
MACOS_NOTARY_KEY: "${{ secrets.MACOS_NOTARY_KEY }}"
release-info:
needs: release
name: Generate Release Info
uses: ./.github/workflows/release-info.yaml
5 changes: 5 additions & 0 deletions .github/workflows/release-sdk-as.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:

jobs:
release:
name: Release
# note: must use GitHub-hosted runner for publishing to NPM with --provenance flag
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -49,3 +50,7 @@ jobs:
sdk/assemblyscript/templates_assemblyscript_${{ steps.parse_sdk_version.outputs.sdk_version }}.tar.gz
prerelease: ${{ contains(steps.parse_sdk_version.outputs.sdk_version, '-') }}
make_latest: false
release-info:
needs: release
name: Generate Release Info
uses: ./.github/workflows/release-info.yaml
5 changes: 5 additions & 0 deletions .github/workflows/release-sdk-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
release:
name: Release
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: Validate version
Expand Down Expand Up @@ -38,3 +39,7 @@ jobs:
sdk/go/templates_go_${{ steps.parse_sdk_version.outputs.sdk_version }}.tar.gz
prerelease: ${{ contains(steps.parse_sdk_version.outputs.sdk_version, '-') }}
make_latest: false
release-info:
needs: release
name: Generate Release Info
uses: ./.github/workflows/release-info.yaml
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## UNRELEASED

- Automatically generate and push releases info to R2 bucket on every release [#526](https://github.com/hypermodeinc/modus/pull/526)
- Consistent help + print enum options + validate SDK prereq [#542](https://github.com/hypermodeinc/modus/pull/542)
- Consistent padding in the help section
- `modus new`: Enum options need to print possible options
Expand Down
2 changes: 2 additions & 0 deletions tools/release-info/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
modus-*.json
4 changes: 4 additions & 0 deletions tools/release-info/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": false,
"printWidth": 1024
}
22 changes: 22 additions & 0 deletions tools/release-info/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

export const GitHubOwner = "hypermodeinc";
export const GitHubRepo = "modus";
export const GitHubRuntimeTagPrefix = "runtime/";
export const GitHubCliTagPrefix = "cli/";

export function GetSdkTagPrefix(sdk: SDK): string {
return `sdk/${sdk.toLowerCase()}/`;
}

export enum SDK {
AssemblyScript = "AssemblyScript",
Go = "Go",
}
6 changes: 6 additions & 0 deletions tools/release-info/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended);
46 changes: 46 additions & 0 deletions tools/release-info/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2024 Hypermode Inc.
* Licensed under the terms of the Apache License, Version 2.0
* See the LICENSE file that accompanied this code for further details.
*
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

import { getLatestSdkVersion, getLatestRuntimeVersion, getLatestCliVersion, getAllSdkVersions, getAllRuntimeVersions, getAllCliVersions } from "./versioninfo.js";
import { SDK } from "./constants.js";
import { writeFile } from "fs/promises";

async function buildModusLatestJSON(filename: string, includePrerelease: boolean) {
const as = await getLatestSdkVersion(SDK.AssemblyScript, includePrerelease);
const go = await getLatestSdkVersion(SDK.Go, includePrerelease);
const cli = await getLatestCliVersion(includePrerelease);
const runtime = await getLatestRuntimeVersion(includePrerelease);
const info = {
"sdk/assemblyscript": as,
"sdk/go": go,
cli: cli,
runtime: runtime,
};

await writeFile(filename, JSON.stringify(info, null, 2));
}

async function buildModusAllJSON(filename: string, includePrerelease: boolean) {
const as = await getAllSdkVersions(SDK.AssemblyScript, includePrerelease);
const go = await getAllSdkVersions(SDK.Go, includePrerelease);
const cli = await getAllCliVersions(includePrerelease);
const runtime = await getAllRuntimeVersions(includePrerelease);
const info = {
"sdk/assemblyscript": as,
"sdk/go": go,
cli: cli,
runtime: runtime,
};
await writeFile(filename, JSON.stringify(info, null, 2));
}

await buildModusLatestJSON("modus-latest.json", false);
await buildModusLatestJSON("modus-preview.json", true);
await buildModusAllJSON("modus-all.json", false);
await buildModusAllJSON("modus-preview-all.json", true);
Loading

0 comments on commit f8657fb

Please sign in to comment.