Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically generate and push release info to R2 bucket on every release #526

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ permissions:
id-token: write
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 @@ -46,3 +47,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 @@ -7,6 +7,7 @@ permissions:
contents: "write"
jobs:
release:
name: Release
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: "Validate version"
Expand Down Expand Up @@ -34,3 +35,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 @@ -8,6 +8,7 @@ permissions:
id-token: write
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 @@ -46,3 +47,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 @@ -7,6 +7,7 @@ permissions:
contents: "write"
jobs:
release:
name: Release
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: "Validate version"
Expand Down Expand Up @@ -35,3 +36,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
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",
}
56 changes: 56 additions & 0 deletions tools/release-info/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 { writeFileSync } from "fs";

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,
};

writeFileSync(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,
};
writeFileSync(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);
55 changes: 55 additions & 0 deletions tools/release-info/package-lock.json

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

26 changes: 26 additions & 0 deletions tools/release-info/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@hypermode/release-info",
"version": "",
"description": "Generates release information for the Modus CLI",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"build": "rm -rf dist && tsc -b",
"watch": "rm -rf dist && tsc -b -w"
},
"repository": "github:hypermodeinc/modus",
"author": "Hypermode Inc.",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/hypermodeinc/modus/issues"
},
"homepage": "https://github.com/hypermodeinc/modus",
"dependencies": {
"semver": "^7.6.3"
},
"devDependencies": {
"@types/node": "^22.8.6",
"@types/semver": "^7.5.8"
}
}
15 changes: 15 additions & 0 deletions tools/release-info/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"declaration": true,
"module": "NodeNext",
"outDir": "dist",
"strict": true,
"target": "ESNext",
"moduleResolution": "NodeNext",
"sourceMap": true
},
"include": ["./*"],
"ts-node": {
"esm": true
}
}
Loading