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 all 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
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 @@ -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
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