diff --git a/.changeset/config.json b/.changeset/config.json index a01341a4efa..cdc4180d3e9 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -30,5 +30,9 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": [] + "ignore": [], + "snapshot": { + "useCalculatedVersion": true, + "prereleaseTemplate": "{tag}.{commit}" + } } diff --git a/.github/workflows/npm-beta-release.yml b/.github/workflows/npm-beta-release.yml new file mode 100644 index 00000000000..d63bd0783d3 --- /dev/null +++ b/.github/workflows/npm-beta-release.yml @@ -0,0 +1,93 @@ +name: NPM Beta Release + +on: + workflow_dispatch: + inputs: + snapshot_tag: + description: 'NPM dist-tag for the beta release' + required: true + default: 'beta' + type: choice + options: + - beta + - alpha + - rc + - preview + +concurrency: + group: npm-beta-release + cancel-in-progress: false + +env: + LOG_FORMAT: PRETTY + TURBO_TELEMETRY_DISABLED: 1 + TURBO_API: https://cache.depot.dev + TURBO_TOKEN: ${{ secrets.DEPOT_TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.DEPOT_ORG_ID }} + +jobs: + beta-release: + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: .nvmrc + registry-url: 'https://registry.npmjs.org' + + - name: Check for changesets + run: | + CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" ! -name "config.json" 2>/dev/null | wc -l | tr -d ' ') + if [ "$CHANGESET_COUNT" -eq 0 ]; then + echo "::error::No pending changesets found. Beta releases require pending changeset files." + echo "" + echo "To create a beta release:" + echo "1. Add a changeset: yarn changeset" + echo "2. Commit the changeset file" + echo "3. Run this workflow again" + exit 1 + fi + echo "Found $CHANGESET_COUNT changeset(s)" + + - name: Install dependencies + run: yarn install --immutable + + - name: Create snapshot versions + run: yarn changeset version --snapshot ${{ inputs.snapshot_tag }} + + - name: Get snapshot version + id: version + run: | + SNAPSHOT_VERSION=$(node -p "require('./typescript/sdk/package.json').version") + echo "snapshot=$SNAPSHOT_VERSION" >> $GITHUB_OUTPUT + + - name: Build packages + run: yarn build + + - name: Publish beta packages + run: yarn changeset publish --tag ${{ inputs.snapshot_tag }} --no-git-tag + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true + + - name: Summary + run: | + echo "### Beta Release Published" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Version:** \`${{ steps.version.outputs.snapshot }}\`" >> $GITHUB_STEP_SUMMARY + echo "**NPM Tag:** \`${{ inputs.snapshot_tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "**Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Install with:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY + echo "npm install @hyperlane-xyz/sdk@${{ inputs.snapshot_tag }}" >> $GITHUB_STEP_SUMMARY + echo "npm install @hyperlane-xyz/cli@${{ inputs.snapshot_tag }}" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ec77b87401..bdc74f67fed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,6 +59,7 @@ jobs: id: changesets uses: changesets/action@v1 with: + title: 'chore: release npm packages' version: yarn version:prepare env: NPM_CONFIG_PROVENANCE: true diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.yml index be45fcc0cfe..bf0f1facd5f 100644 --- a/.github/workflows/rust-release.yml +++ b/.github/workflows/rust-release.yml @@ -279,12 +279,19 @@ jobs: # Determine final version based on release type # workflow_dispatch always creates pre-releases if [ "$IS_PRERELEASE" = "true" ]; then - # Pre-release: append suffix + # For prereleases, calculate the next version (like changesets does for NPM) + # This ensures prerelease versions reflect what the next release will be + # e.g., if current is 1.7.0, prerelease will be 1.8.0-preview.1 (not 1.7.0-preview.1) + OUTPUT=$(./rust/scripts/ci/determine-next-version.sh "$BASE_VERSION") + NEXT_VERSION=$(echo "$OUTPUT" | sed -n '1p') + echo "Calculated next version: $NEXT_VERSION (from base $BASE_VERSION)" + + # Pre-release: append suffix to the NEXT version if [ -n "$PRERELEASE_SUFFIX" ]; then SUFFIX="$PRERELEASE_SUFFIX" else # Auto-generate preview.N - LAST_PREVIEW=$(git tag -l "agents-v${BASE_VERSION}-preview.*" | sort -V | tail -1) + LAST_PREVIEW=$(git tag -l "agents-v${NEXT_VERSION}-preview.*" | sort -V | tail -1) if [ -z "$LAST_PREVIEW" ]; then SUFFIX="preview.1" else @@ -292,7 +299,7 @@ jobs: SUFFIX="preview.$((PREVIEW_NUM + 1))" fi fi - VERSION="${BASE_VERSION}-${SUFFIX}" + VERSION="${NEXT_VERSION}-${SUFFIX}" TITLE="Agents $VERSION (Pre-release)" PRERELEASE_FLAG="--prerelease" RELEASE_TYPE="Pre-release"