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 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..b3db4fd26 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/shared-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/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: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main + uses: ./.github/workflows/shared-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..2981d4745 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 @@ -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.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 new file mode 100644 index 000000000..5be2b3da6 --- /dev/null +++ b/.github/workflows/shared-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@v1.2.2 + with: + preCommit: ${{ inputs.preCommit }} + env: + GITHUB_TOKEN: ${{ secrets.githubToken }} diff --git a/.github/workflows/shared-release-snapshot.yml b/.github/workflows/shared-release-snapshot.yml new file mode 100644 index 000000000..618bca3c2 --- /dev/null +++ b/.github/workflows/shared-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.3 + with: + tag: ${{ inputs.npmTag }} + prepareScript: '${{inputs.packageManager}} run ${{ inputs.buildScript }}' + env: + NPM_TOKEN: ${{ secrets.npmToken }} + GITHUB_TOKEN: ${{ secrets.githubToken }}