refactor: rename all instances of maxRealtimeDistance to `maxWorstC…
#1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| changesets: | |
| name: Changesets | |
| if: github.repository == 'namehash/ensnode' | |
| runs-on: blacksmith-4vcpu-ubuntu-2204 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| publishedApps: ${{ steps.publishedApps.outputs.output }} | |
| publishedPackages: ${{ steps.publishedPackages.outputs.output }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: useblacksmith/setup-node@v5 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Create Release Pull Request or Publish to npm | |
| uses: changesets/action@v1.4.10 | |
| id: changesets | |
| with: | |
| commit: "chore(release): version apps" | |
| title: "Release New Version" | |
| publish: pnpm changeset-publish | |
| createGithubReleases: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Filter Published Packages For Apps | |
| uses: cloudposse/github-action-jq@main | |
| id: publishedApps | |
| with: | |
| compact: true | |
| input: ${{ steps.changesets.outputs.publishedPackages }} | |
| # filter publishedPackages for apps (projects whose artifact is a docker image) | |
| script: |- | |
| map(select( | |
| .name == "ensindexer" | |
| or .name == "ensadmin" | |
| or .name == "ensapi" | |
| or .name == "ensrainbow" | |
| )) | |
| - name: Filter Published Packages For NPM Packages | |
| uses: cloudposse/github-action-jq@main | |
| id: publishedPackages | |
| with: | |
| compact: true | |
| input: ${{ steps.changesets.outputs.publishedPackages }} | |
| # filter publishedPackages for packages (projects whose artifact is an NPM package) | |
| # 1. filter out publishedApps (see above) | |
| # 2. filter out private packages that were not actually published to NPM | |
| # a. @ensnode/shared-configs | |
| # b. @docs/* | |
| script: |- | |
| map(select( | |
| .name != "ensindexer" | |
| and .name != "ensadmin" | |
| and .name != "ensapi" | |
| and .name != "ensrainbow" | |
| and .name != "@ensnode/shared-configs" | |
| and (.name | startswith("@docs") | not) | |
| )) | |
| build-and-push-ensnode: | |
| name: ${{ matrix.apps.name }} ${{ matrix.apps.version }} | |
| # if changesets published our npm packages, also build docker images | |
| needs: changesets | |
| if: needs.changesets.outputs.published == 'true' && needs.changesets.outputs.publishedApps != '[]' | |
| runs-on: blacksmith-4vcpu-ubuntu-2204 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| apps: ${{ fromJson(needs.changesets.outputs.publishedApps) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Build & Push | |
| uses: ./.github/actions/build_docker_image | |
| with: | |
| image: ghcr.io/${{ github.repository }}/${{ matrix.apps.name }} | |
| dockerfile: apps/${{ matrix.apps.name }}/Dockerfile | |
| registry_user: ${{ github.actor }} | |
| registry_token: ${{ secrets.GITHUB_TOKEN }} | |
| # construct docker tag using the changesets-reported version | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ matrix.apps.version }} | |
| type=ref,event=branch | |
| type=sha | |
| create-github-release: | |
| name: Create GitHub Release | |
| runs-on: blacksmith-4vcpu-ubuntu-2204 | |
| # run only if (1) changesets published our npm packages AND | |
| if: needs.changesets.outputs.published == 'true' | |
| # (2) we built and pushed the docker images | |
| needs: [changesets, build-and-push-ensnode] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get PR information | |
| id: get-pr | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Get the PR number from the commit message | |
| # Note: it must be a release PR with a title "Release New Version" | |
| PR_NUMBER=$(git log -1 --pretty=%B | grep -o 'Release New Version (#[0-9]\+)' | grep -o '[0-9]\+') | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "Could not find PR number in commit message" | |
| exit 1 | |
| fi | |
| # Get PR body using GitHub CLI | |
| PR_BODY=$(gh pr view $PR_NUMBER --json body -q .body) | |
| if [ -z "$PR_BODY" ]; then | |
| echo "Could not fetch PR body" | |
| exit 1 | |
| fi | |
| # Extract version from PR body | |
| VERSION=$(echo "$PR_BODY" | grep -o '@[^@]*@[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | awk -F@ '{print $3}') | |
| if [ -z "$VERSION" ]; then | |
| echo "Could not extract version from PR body" | |
| exit 1 | |
| fi | |
| # Extract release notes (everything below # Releases) | |
| RELEASE_NOTES=$(echo "$PR_BODY" | awk '/^# Releases/{p=1;next}p') | |
| # Strip out @ensnode/shared-configs section (thank you claude-san) | |
| RELEASE_NOTES=$(echo "$RELEASE_NOTES" | awk ' | |
| /^## @ensnode\/shared-configs@.*/ { skip=1; next } # Set skip flag and skip further processing for this line | |
| /^## / { skip=0 } # On subsequent lines, clear skip flag if H2 is found | |
| !skip # Print line only if skip flag is not set | |
| ') | |
| # Add NPM package links | |
| RELEASE_NOTES+=$'\n\n## :package: NPM packages\n' | |
| RELEASE_NOTES+=$(echo '${{ needs.changesets.outputs.publishedPackages }}' | jq -r '.[] | "- [\(.name)@\(.version)](https://www.npmjs.com/package/\(.name)/v/\(.version))"') | |
| # Add Docker image links | |
| RELEASE_NOTES+=$'\n\n## :whale: Docker images\n' | |
| RELEASE_NOTES+=$(echo '${{ needs.changesets.outputs.publishedApps }}' | jq -r '.[] | "- [\(.name):\(.version)](https://ghcr.io/namehash/ensnode/\(.name):\(.version))"') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "pr_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.get-pr.outputs.version }} | |
| name: v${{ steps.get-pr.outputs.version }} | |
| body: ${{ steps.get-pr.outputs.pr_body }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: ./.github/actions/send_slack_notification | |
| with: | |
| slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| slack_title: "ENSNode new version released: v${{ steps.get-pr.outputs.version }}" | |
| slack_message: "✅ Release ENSNode completed" |