From 95a2111b1cc2126bbdd2fd7f6961f4dcfd309d37 Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Sat, 25 Jan 2025 00:11:01 -0500 Subject: [PATCH 1/5] move actions and workflows locally --- .github/actions/setup-node/action.yml | 85 ++++++++++++++++++ .github/workflows/ci.yml | 8 +- .github/workflows/pr.yml | 6 +- .github/workflows/release.yml | 2 +- .../reusable/changesets-dependencies.yml | 54 ++++++++++++ .../workflows/reusable/release-snapshot.yml | 88 +++++++++++++++++++ 6 files changed, 235 insertions(+), 8 deletions(-) create mode 100644 .github/actions/setup-node/action.yml create mode 100644 .github/workflows/reusable/changesets-dependencies.yml create mode 100644 .github/workflows/reusable/release-snapshot.yml diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 000000000..ba61a87cc --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,85 @@ +# Note: This is a composite GitHub Actions, it should do all env setup, caching an so on, so other pipelines can just compose their own stuff on top of that. +# Docs: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + +name: Configure Environment +description: Shared configuration for checkout, Node.js and package manager +inputs: + nodeVersion: + description: Node.js version to use + required: true + default: '20' + workingDirectory: + description: Working directory + required: false + default: ./ + packageManager: + description: Package manager + required: false + default: yarn + packageManagerVersion: + description: Package manager version + required: false + default: '' + +runs: + using: composite + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + continue-on-error: true + with: + access_token: ${{ github.token }} + + - name: check pnpm version + shell: bash + id: pnpm + if: inputs.packageManager == 'pnpm' + working-directory: ${{ inputs.workingDirectory }} + run: | + PNPM_VERSION=${PNPM_VERSION:-9.0.6} + PKG_JSON=$(cat package.json | jq -r '.packageManager' | awk -F@ '{print $2}') + if [ ! -z $PKG_JSON ]; then + PNPM_VERSION=$PKG_JSON + fi + if [ ! -z {{inputs.packageManager}} ]; then + PNPM_VERSION=${{ inputs.packageManagerVersion }} + fi + echo "Using PNPM version $PNPM_VERSION" + echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT + + - name: Setup ${{ inputs.packageManager }} + id: pnpm_setup + if: inputs.packageManager == 'pnpm' + uses: pnpm/action-setup@v4.0.0 + with: + version: ${{ steps.pnpm.outputs.version }} + run_install: false + package_json_file: ${{ inputs.workingDirectory }}/package.json + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.nodeVersion }} + cache: ${{ inputs.packageManager }} + cache-dependency-path: | + **/pnpm-lock.yaml + **/yarn.lock + patches/** + + - name: yarn install + shell: bash + if: inputs.packageManager == 'yarn' && inputs.packageManagerVersion == '' + run: yarn install --ignore-engines --frozen-lockfile --immutable + working-directory: ${{ inputs.workingDirectory }} + + - name: modern yarn install + shell: bash + if: inputs.packageManager == 'yarn' && inputs.packageManagerVersion == 'modern' + run: corepack enable && yarn + working-directory: ${{ inputs.workingDirectory }} + + - name: pnpm install + shell: bash + if: inputs.packageManager == 'pnpm' + run: pnpm install --frozen-lockfile + working-directory: ${{ inputs.workingDirectory }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c08326b51..880ebe653 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - uses: the-guild-org/shared-config/setup@main + - uses: ./.github/actions/setup-node name: Setup Env with: nodeVersion: 20 @@ -37,7 +37,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - uses: the-guild-org/shared-config/setup@main + - uses: ./.github/actions/setup-node name: Setup Env with: nodeVersion: ${{ matrix.node-version }} @@ -67,7 +67,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - uses: the-guild-org/shared-config/setup@main + - uses: ./.github/actions/setup-node name: Setup Env with: nodeVersion: 20 @@ -95,7 +95,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - uses: the-guild-org/shared-config/setup@main + - uses: ./.github/actions/setup-node name: Setup Env with: nodeVersion: 20 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f8f31a8a0..420efdea0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,13 @@ permissions: write-all jobs: dependencies: - uses: the-guild-org/shared-config/.github/workflows/changesets-dependencies.yaml@main + uses: ./.github/workflows/reusable/changesets-dependencies.yml if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }} secrets: githubToken: ${{ secrets.GITHUB_TOKEN }} alpha: - uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main + uses: ./.github/workflows/reusable/release-snapshot.yml if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }} with: npmTag: alpha @@ -27,7 +27,7 @@ jobs: npmToken: ${{ secrets.NPM_TOKEN }} release-candidate: - uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main + uses: ./.github/workflows/reusable/release-snapshot.yml if: ${{ github.event.pull_request.title == 'Upcoming Release Changes' }} with: npmTag: rc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63b482f37..59cfe9772 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup environment - uses: the-guild-org/shared-config/setup@main + uses: ./.github/actions/setup-node with: nodeVersion: 20 packageManager: pnpm diff --git a/.github/workflows/reusable/changesets-dependencies.yml b/.github/workflows/reusable/changesets-dependencies.yml new file mode 100644 index 000000000..de3c5d491 --- /dev/null +++ b/.github/workflows/reusable/changesets-dependencies.yml @@ -0,0 +1,54 @@ +# Note: this is a shared pipeline used by other repositories. +# Docs: https://docs.github.com/en/actions/using-workflows/reusing-workflows + +on: + workflow_call: + inputs: + installDependencies: + type: boolean + default: false + preCommit: + type: string + required: false + packageManager: + type: string + required: false + default: yarn + packageManagerVersion: + type: string + description: Package manager version + required: false + default: '' + nodeVersion: + required: false + type: string + default: '20' + secrets: + githubToken: + required: true + +jobs: + changeset: + runs-on: ubuntu-24.04 + if: github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.githubToken }} + + - uses: ./.github/actions/setup-node + name: setup env and install dependencies + if: ${{ inputs.installDependencies }} + with: + nodeVersion: ${{ inputs.nodeVersion }} + packageManager: ${{ inputs.packageManager }} + packageManagerVersion: ${{ inputs.packageManagerVersion }} + + - name: Create/Update Changesets + uses: pinax-network/changesets-dependencies-action@main + with: + preCommit: ${{ inputs.preCommit }} + env: + GITHUB_TOKEN: ${{ secrets.githubToken }} diff --git a/.github/workflows/reusable/release-snapshot.yml b/.github/workflows/reusable/release-snapshot.yml new file mode 100644 index 000000000..600a80c59 --- /dev/null +++ b/.github/workflows/reusable/release-snapshot.yml @@ -0,0 +1,88 @@ +# Note: this is a shared pipeline used by other repositories. +# Docs: https://docs.github.com/en/actions/using-workflows/reusing-workflows + +on: + workflow_call: + inputs: + packageManager: + type: string + required: false + default: yarn + packageManagerVersion: + description: Package manager version + type: string + required: false + default: '' + nodeVersion: + required: false + type: string + default: '20' + buildScript: + required: false + type: string + default: build + npmTag: + required: false + type: string + default: npmTag + exitPre: + required: false + type: boolean + default: false + restoreDeletedChangesets: + required: false + type: boolean + default: false + secrets: + githubToken: + required: true + npmToken: + required: true + outputs: + published: + description: A boolean value to indicate whether a publishing is happened or not + value: ${{ jobs.snapshot.outputs.published }} + publishedPackages: + description: + 'A JSON array to present the published packages. The format is [{"name": "@xx/xx", + "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]' + value: ${{ jobs.snapshot.outputs.publishedPackages }} + +jobs: + snapshot: + runs-on: ubuntu-24.04 + if: github.event.pull_request.head.repo.full_name == github.repository + outputs: + published: ${{ steps.changesets.outputs.published }} + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + + - uses: ./.github/actions/setup-node + name: setup env + with: + nodeVersion: ${{inputs.nodeVersion}} + packageManager: ${{inputs.packageManager}} + packageManagerVersion: ${{inputs.packageManagerVersion}} + + - if: inputs.exitPre + name: Exit Prerelease Mode + run: ${{inputs.packageManager}} run changeset pre exit + + - if: inputs.restoreDeletedChangesets + name: restore deleted changesets + run: git checkout HEAD~1 -- . + + - name: ${{ inputs.npmTag }} release + id: changesets + uses: pinax-network/changesets-snapshot-action@v0.0.2 + with: + tag: ${{ inputs.npmTag }} + prepareScript: '${{inputs.packageManager}} run ${{ inputs.buildScript }}' + env: + NPM_TOKEN: ${{ secrets.npmToken }} + GITHUB_TOKEN: ${{ secrets.githubToken }} From b9864eb0544fdfc4b208d4bf489ed67ca49866f0 Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Sat, 25 Jan 2025 11:41:33 -0500 Subject: [PATCH 2/5] move shared workflows --- .github/workflows/pr.yml | 6 +++--- ...-dependencies.yml => shared-changesets-dependencies.yml} | 0 .../release-snapshot.yml => shared-release-snapshot.yml} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{reusable/changesets-dependencies.yml => shared-changesets-dependencies.yml} (100%) rename .github/workflows/{reusable/release-snapshot.yml => shared-release-snapshot.yml} (100%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 420efdea0..b3db4fd26 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,13 @@ permissions: write-all jobs: dependencies: - uses: ./.github/workflows/reusable/changesets-dependencies.yml + uses: ./.github/workflows/shared-changesets-dependencies.yml if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }} secrets: githubToken: ${{ secrets.GITHUB_TOKEN }} alpha: - uses: ./.github/workflows/reusable/release-snapshot.yml + uses: ./.github/workflows/shared-release-snapshot.yml if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }} with: npmTag: alpha @@ -27,7 +27,7 @@ jobs: npmToken: ${{ secrets.NPM_TOKEN }} release-candidate: - uses: ./.github/workflows/reusable/release-snapshot.yml + uses: ./.github/workflows/shared-release-snapshot.yml if: ${{ github.event.pull_request.title == 'Upcoming Release Changes' }} with: npmTag: rc diff --git a/.github/workflows/reusable/changesets-dependencies.yml b/.github/workflows/shared-changesets-dependencies.yml similarity index 100% rename from .github/workflows/reusable/changesets-dependencies.yml rename to .github/workflows/shared-changesets-dependencies.yml diff --git a/.github/workflows/reusable/release-snapshot.yml b/.github/workflows/shared-release-snapshot.yml similarity index 100% rename from .github/workflows/reusable/release-snapshot.yml rename to .github/workflows/shared-release-snapshot.yml From 6d5e857b19eb39abfc99e0871b48a8c10b7cf741 Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Sat, 25 Jan 2025 12:57:31 -0500 Subject: [PATCH 3/5] changeset --- .changeset/smooth-poets-rush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smooth-poets-rush.md diff --git a/.changeset/smooth-poets-rush.md b/.changeset/smooth-poets-rush.md new file mode 100644 index 000000000..b7707aec3 --- /dev/null +++ b/.changeset/smooth-poets-rush.md @@ -0,0 +1,5 @@ +--- +'@graphprotocol/graph-cli': patch +--- + +chore: move github actions around From 268f64cdef82c65c8b20801784fbc1ac9f8b5b5a Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Sat, 25 Jan 2025 16:13:45 -0500 Subject: [PATCH 4/5] update action repo --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59cfe9772..ddd190d02 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }} run: pnpm --filter=@graphprotocol/graph-cli oclif:pack - name: Release / pull_request - uses: dotansimha/changesets-action@v1.5.0 + uses: pinax-network/changesets-release-action@v1.5.0 with: publish: pnpm release version: pnpm changeset version From 9cbb8405b51abdabee32d4532bb449571bd862b7 Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Sat, 25 Jan 2025 22:09:05 -0500 Subject: [PATCH 5/5] update action versions --- .github/workflows/release.yml | 2 +- .github/workflows/shared-changesets-dependencies.yml | 2 +- .github/workflows/shared-release-snapshot.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddd190d02..2981d4745 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }} run: pnpm --filter=@graphprotocol/graph-cli oclif:pack - name: Release / pull_request - uses: pinax-network/changesets-release-action@v1.5.0 + uses: pinax-network/changesets-release-action@v1.5.2 with: publish: pnpm release version: pnpm changeset version diff --git a/.github/workflows/shared-changesets-dependencies.yml b/.github/workflows/shared-changesets-dependencies.yml index de3c5d491..5be2b3da6 100644 --- a/.github/workflows/shared-changesets-dependencies.yml +++ b/.github/workflows/shared-changesets-dependencies.yml @@ -47,7 +47,7 @@ jobs: packageManagerVersion: ${{ inputs.packageManagerVersion }} - name: Create/Update Changesets - uses: pinax-network/changesets-dependencies-action@main + uses: pinax-network/changesets-dependencies-action@v1.2.2 with: preCommit: ${{ inputs.preCommit }} env: diff --git a/.github/workflows/shared-release-snapshot.yml b/.github/workflows/shared-release-snapshot.yml index 600a80c59..618bca3c2 100644 --- a/.github/workflows/shared-release-snapshot.yml +++ b/.github/workflows/shared-release-snapshot.yml @@ -79,7 +79,7 @@ jobs: - name: ${{ inputs.npmTag }} release id: changesets - uses: pinax-network/changesets-snapshot-action@v0.0.2 + uses: pinax-network/changesets-snapshot-action@v0.0.3 with: tag: ${{ inputs.npmTag }} prepareScript: '${{inputs.packageManager}} run ${{ inputs.buildScript }}'