Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/nice-chefs-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/token-balance-adapter': minor
---

testing workflow
5 changes: 5 additions & 0 deletions .changeset/tall-roses-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/aleno-adapter': minor
---

testing workflow
22 changes: 22 additions & 0 deletions .github/scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

args_to_ignore=()
args_adapters=()

if [[ -n "${1:-}" ]]; then
eas_to_include="$(echo "$*" | sed -e 's/ *, */ /g' | tr ' ' '\n')"
packages_to_include="$(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|.*|@chainlink/&-adapter|')"

all_packages=$(yarn workspaces list --json | jq -r '.name' | grep -v '@chainlink/external-adapters-js')

args_to_ignore=($(echo "$all_packages" | grep -vFf <(echo "$packages_to_include" | tr ' ' '\n') | sed -e 's|^|--ignore |'))
args_adapters=($(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|^|--adapters &|'))
fi

export UPSTREAM_BRANCH=main
yarn changeset version "${args_to_ignore[@]}"
yarn generate:master-list -v
yarn generate:readme -v "${args_adapters[*]}"
git add MASTERLIST.md "*README.md"
yarn lint-staged
15 changes: 15 additions & 0 deletions .github/scripts/packages-to-ignore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ -z "${1:-}" ]]; then
exit 0
fi

eas_to_include="$(echo "$*" | sed -e 's/ *, */ /g' | tr ' ' '\n')"
packages_to_include="$(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|.*|@chainlink/&-adapter|')"

all_packages=$(yarn workspaces list --json | jq -r '.name' | grep -v '@chainlink/external-adapters-js')

packages_to_ignore="$(echo "$all_packages" | grep -vFf <(echo "$packages_to_include" | tr ' ' '\n'))"

echo "$packages_to_ignore"
4 changes: 2 additions & 2 deletions .github/scripts/run-changesets.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

# Run changesets
yarn changeset version
yarn changeset version "$@"

# Recover all our changes (readmes, version bump)
git stash pop
git stash pop
102 changes: 102 additions & 0 deletions .github/workflows/release-individual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Release individual adapters

# Creates PRs in external-adapters-js and infra-k8s to release individually selected adapters.

on:
workflow_dispatch:
inputs:
adapters:
description: Comma-separated list of adapter names to release
required: true

jobs:
consume-changesets:
name: Upsert Release PR
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPSTREAM_BRANCH: 'main'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
# We install only the changesets tool so we can do the mock changesets before installing dependencies,
# as the setup action will only build the files relevant to the changed adapters
- name: Install changesets tool
run: |
yarn add @changesets/cli@$(jq -r '.devDependencies."@changesets/cli"' package.json)
- name: Configure git
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set CHANGESET_IGNORE_ARGS env var
run: |
CHANGESET_IGNORE_ARGS="$(.github/scripts/packages-to-ignore.sh ${{ github.event.inputs.adapters }} | sed -e 's/^/--ignore /' | tr '\n' ' ')"
echo "$CHANGESET_IGNORE_ARGS"
echo "CHANGESET_IGNORE_ARGS=$CHANGESET_IGNORE_ARGS" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Temporarily calculate changesets to generate readmes with proper versions
run: |
# Get from output of previous step:
PACKAGES_TO_IGNORE="${{ env.packages_to_ignore }}"
yarn changeset version $CHANGESET_IGNORE_ARGS
git add -A
git commit -m "Changesets mock"
- name: Set up and install dependencies
uses: ./.github/actions/setup
with:
build-all: 'true'
- name: Increase monorepo version
run: |
BUMPED_VERSION=$(jq -r '.version | split(".")[1] | tonumber | . + 1 | tostring | "1." + . + ".0"' package.json)
jq ".version = \"$BUMPED_VERSION\"" package.json > package.tmp.json
mv package.tmp.json package.json
echo "BUMPED_VERSION=$BUMPED_VERSION" >> $GITHUB_ENV
- name: Generate documentation
run: |
yarn generate:master-list -v
yarn generate:readme -v
- name: Undo temporary changesets and commit docs
run: |
git stash
git reset HEAD^ --hard
git stash pop
- name: Commit docs
run: |
git add MASTERLIST.md
git add "*README.md"
yarn lint-staged
- name: Stash changes for changesets action to pick up in custom script
run: |
git stash
- name: Create Release Pull Request
uses: smartcontractkit/.github/actions/signed-commits@4b7aa1d5b60f0d5704400a1d2b192905ad386e6c # changesets-signed-commits@1.2.4
with:
# This version command is not only necessary because of yarn pnp, but because the changeset action
# performs git resets and we want to keep those changes, so we stash and then pop them here.
# All the previous steps would technically make more sense in the script itself, but we
# keep them as separate ones so it's easier to see them from the github UI to debug.
version: ./.github/scripts/run-changesets.sh ${{ env.CHANGESET_IGNORE_ARGS }}
title: 'testing Release ${{ env.BUMPED_VERSION }}'
commit: 'testing Release ${{ env.BUMPED_VERSION }}'
- name: Tag changesets commit
run: |
# Delete the tags if they already exist (ignore errors if they don't)
#git tag -d "v$BUMPED_VERSION" || true
#git push --delete origin "v$BUMPED_VERSION" || true
#git tag "v$BUMPED_VERSION"
#git push origin "v$BUMPED_VERSION"
# Because the workflows won't run and we technically don't need them for this autogenerated PR,
# we manually skip all the required checks by using the GitHub API directly.
- name: Skip required checks manually
run: |
COMMIT_SHA=$(git rev-parse HEAD)
./.github/scripts/skip-check.sh $COMMIT_SHA "Adapter changes accompanied by a changeset"
./.github/scripts/skip-check.sh $COMMIT_SHA "Documentation generation test"
./.github/scripts/skip-check.sh $COMMIT_SHA "Install and verify dependencies"
./.github/scripts/skip-check.sh $COMMIT_SHA "Run integration tests for changed adapters"
./.github/scripts/skip-check.sh $COMMIT_SHA "Run linters and formatters"
./.github/scripts/skip-check.sh $COMMIT_SHA "Run unit tests for changed adapters"
Comment on lines +14 to +102

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 12 days ago

To fix this issue, add a permissions block specifying the minimal required permissions for the job or workflow. The block can be added either at the workflow level (top-level, before jobs:) to apply to all jobs, or within each individual job if some jobs need broader permissions than others. For this workflow, since all operations are within a single job (consume-changesets), add the block to that job. As a minimum, set contents: write since the job performs git commits and push operations, and may require write access to repository contents. If the job interacts with issues or pull requests (as seems likely due to the creation of release PRs), also consider pull-requests: write. If only reading contents is required, specify contents: read. Adjust permissions according to the tasks performed—here, contents: write and pull-requests: write are suitable starting points.

Specifically:

  • Edit .github/workflows/release-individual.yml, in the jobs.consume-changesets block (preferably immediately below name: Upsert Release PR, but any location within the job is valid).
  • Add:
      permissions:
        contents: write
        pull-requests: write
  • No imports or definitions needed beyond standard GitHub Actions YAML.
  • No other file changes are required.

Suggested changeset 1
.github/workflows/release-individual.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/release-individual.yml b/.github/workflows/release-individual.yml
--- a/.github/workflows/release-individual.yml
+++ b/.github/workflows/release-individual.yml
@@ -12,6 +12,9 @@
 jobs:
   consume-changesets:
     name: Upsert Release PR
+    permissions:
+      contents: write
+      pull-requests: write
     runs-on: ubuntu-latest
     env:
       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EOF
@@ -12,6 +12,9 @@
jobs:
consume-changesets:
name: Upsert Release PR
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copilot is powered by AI and may make mistakes. Always verify output.
61 changes: 27 additions & 34 deletions .github/workflows/upsert-release-pr.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
name: Upsert Release PR
name: Upsert Release PR (testing individual release)

# Creates PRs in external-adapters-js and infra-k8s to release individually selected adapters.

on:
push:
branches:
- main
# The only commits that will contain changes to the masterlist will be releases
paths-ignore:
- 'MASTERLIST.md'
- 'package.json'
- '.changeset/**'
- 'packages/**/CHANGELOG.md'
- 'packages/**/README.md'
- 'packages/**/package.json'
workflow_dispatch:
inputs:
# For this workflow, BUILD_ALL will only affect the generate documentation step
build-all:
description: whether to run steps for all adapters, regardless of whether they were changed in this event
required: false
default: 'false'

# TODO: This entire workflow would be immensely sped up (~3min -> 30s tops) if:
# - Readme generation did not require built TS files
# - Readme generation was optimized a bit
# - We only installed the changeset package
adapters:
description: Comma-separated list of adapter names to release
required: true

jobs:
consume-changesets:
name: Upsert Release PR
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPSTREAM_BRANCH: 'HEAD~1'
BUILD_ALL: ${{ github.event.inputs.build-all }}
UPSTREAM_BRANCH: 'main'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand All @@ -49,16 +32,22 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set CHANGESET_IGNORE_ARGS env var
run: |
CHANGESET_IGNORE_ARGS="$(.github/scripts/packages-to-ignore.sh ${{ github.event.inputs.adapters }} | sed -e 's/^/--ignore /' | tr '\n' ' ')"
echo "$CHANGESET_IGNORE_ARGS"
echo "CHANGESET_IGNORE_ARGS=$CHANGESET_IGNORE_ARGS" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Temporarily calculate changesets to generate readmes with proper versions
run: |
yarn changeset version
# Get from output of previous step:
PACKAGES_TO_IGNORE="${{ env.packages_to_ignore }}"
yarn changeset version $CHANGESET_IGNORE_ARGS
git add -A
git commit -m "Changesets mock"
- name: Set up and install dependencies
uses: ./.github/actions/setup
with:
base-branch: ${{ env.UPSTREAM_BRANCH }}
# We want to build all packages for the documentation generation step so that the Masterlist is up to date for all EAs
build-all: 'true'
- name: Increase monorepo version
run: |
Expand All @@ -83,23 +72,27 @@ jobs:
- name: Stash changes for changesets action to pick up in custom script
run: |
git stash
- name: Choose a branch for the release PR
run: |
BRANCH_NAME=$(echo release-${{ github.event.inputs.adapters }} | tr ',' '-' | sed -e 's/[^a-zA-Z0-9]/-/g')
git checkout -b "$BRANCH_NAME"
- name: Create Release Pull Request
uses: smartcontractkit/.github/actions/signed-commits@4b7aa1d5b60f0d5704400a1d2b192905ad386e6c # changesets-signed-commits@1.2.4
with:
# This version command is not only necessary because of yarn pnp, but because the changeset action
# performs git resets and we want to keep those changes, so we stash and then pop them here.
# All the previous steps would technically make more sense in the script itself, but we
# keep them as separate ones so it's easier to see them from the github UI to debug.
version: ./.github/scripts/run-changesets.sh
title: 'Release ${{ env.BUMPED_VERSION }}'
commit: 'Release ${{ env.BUMPED_VERSION }}'
version: ./.github/scripts/run-changesets.sh ${{ env.CHANGESET_IGNORE_ARGS }}
title: 'testing Release ${{ env.BUMPED_VERSION }}'
commit: 'testing Release ${{ env.BUMPED_VERSION }}'
- name: Tag changesets commit
run: |
# Delete the tags if they already exist (ignore errors if they don't)
git tag -d "v$BUMPED_VERSION" || true
git push --delete origin "v$BUMPED_VERSION" || true
git tag "v$BUMPED_VERSION"
git push origin "v$BUMPED_VERSION"
#git tag -d "v$BUMPED_VERSION" || true
#git push --delete origin "v$BUMPED_VERSION" || true
#git tag "v$BUMPED_VERSION"
#git push origin "v$BUMPED_VERSION"
# Because the workflows won't run and we technically don't need them for this autogenerated PR,
# we manually skip all the required checks by using the GitHub API directly.
- name: Skip required checks manually
Expand Down
8 changes: 8 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"class-validator": "0.14.2",
"command-line-args": "5.2.1",
"command-line-usage": "6.1.3",
"ini": "^5.0.0",
"json-schema-ref-parser": "9.0.9",
"mockserver-client": "5.11.2",
"rxjs": "7.4.0",
Expand Down
89 changes: 89 additions & 0 deletions packages/scripts/src/create-release-prs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { exec, test } from 'shelljs'
import * as fs from 'fs';
import * as path from 'path';
import * as ini from 'ini';
import commandLineArgs from 'command-line-args'
import commandLineUsage from 'command-line-usage'
import { getWorkspaceAdapters } from '../workspace'

export async function main(): Promise<void | string> {
try {
// Define CLI options
const commandLineOptions = [
{
name: 'adapters',
multiple: true,
defaultOption: true,
description: 'Adapters to include in release PRs',
},
{ name: 'help', alias: 'h', type: Boolean, description: 'Display usage guide' },
]
const options = commandLineArgs(commandLineOptions)

// Generate usage guide
if (options.help) {
const usage = commandLineUsage([
{
header: 'Release PR creation script',
content:
'This script is run from the root of the external-adapter-js/ repo to create a PR in this repo and another PR in infra-k8s to facilitate the release of a subset of adapters.',
},
{
header: 'Options',
optionList: commandLineOptions,
},
{
content:
'Source code: {underline https://github.com/smartcontractkit/external-adapters-\njs/packages/scripts/src/create-release-prs',
},
])
console.log(usage)
return
}

const allAdapters = getWorkspaceAdapters()
const adaptersToIgnore = []
if (options.adapters && options.adapters.length > 0) {
adaptersToIgnore.push(...allAdapters.filter((a) => {
return !options.adapters.includes(a.descopedName) && !options.adapters.includes(a.descopedName.replace(/-adapter$/, ''))
}))
}
const ignoreArgs = adaptersToIgnore.map((a) => `--ignore ${a.name}`).join(' ')

exec(`yarn changeset version ${ignoreArgs}`, {
fatal: true,
})

const awsConfigPath = path.join(process.env.HOME, '.aws', 'config')
const awsConfigText = fs.readFileSync(awsConfigPath).toString()
const awsConfig = ini.parse(awsConfigText)
const awsProfileSdlc = awsConfig['profile sdlc']

if (!awsProfileSdlc) {
throw new Error('AWS profile "sdlc" not found in ~/.aws/config')
}

const sdlcAccountId =

const imageRepo =

Check failure on line 68 in packages/scripts/src/create-release-prs/index.ts

View workflow job for this annotation

GitHub Actions / Install and verify dependencies

Expression expected.

console.log('dskloetx awsConfig', awsConfig['profile sdlc'])

// gh workflow run --repo smartcontractkit/infra-k8s --ref main "Infra-k8s Image Dispatcher" -F imageRepos=795953128386.dkr.ecr.us-west-2.amazonaws.com/adapters/cmeth-adapter -F gitRepo=dskloet-test-fake-repo-name

/*
const testOutput = exec(`yarn test ${this.integrationTestPath}`, {
fatal: true,
silent: true,
env: { ...process.env, ...testEnvOverrides },
}).toString()
*/

process.exit(0)
} catch (error) {
console.error({ error: error.message, stack: error.stack })
process.exit(1)
}
}

main()
Loading
Loading