Skip to content

Commit

Permalink
Update solidity workflow to work for CCIP (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchad committed Jan 23, 2025
1 parent 7f09ac6 commit 61bfdf1
Showing 1 changed file with 78 additions and 15 deletions.
93 changes: 78 additions & 15 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,57 @@ jobs:
name: Tag Check
runs-on: ubuntu-latest
outputs:
is-release: ${{ steps.release-tag-check.outputs.is-release }}
is-pre-release: ${{ steps.release-tag-check.outputs.is-pre-release }}
release-version: ${{ steps.release-tag-check.outputs.release-version }}
pre-release-version: ${{ steps.release-tag-check.outputs.pre-release-version }}
is-release-core: ${{ steps.release-tag-check-core.outputs.is-release }}
is-pre-release-core: ${{ steps.release-tag-check-core.outputs.is-pre-release }}
release-version-core: ${{ steps.release-tag-check-core.outputs.release-version }}
pre-release-version-core: ${{ steps.release-tag-check-core.outputs.pre-release-version }}
is-release-ccip: ${{ steps.release-tag-check-ccip.outputs.is-release }}
is-pre-release-ccip: ${{ steps.release-tag-check-ccip.outputs.is-pre-release }}
release-version-ccip: ${{ steps.release-tag-check-ccip.outputs.release-version }}
pre-release-version-ccip: ${{ steps.release-tag-check-ccip.outputs.pre-release-version }}
steps:
- uses: actions/checkout@v4.2.1
with:
persist-credentials: false
- name: Check release tag
id: release-tag-check
- name: Check release tag (core)
id: release-tag-check-core
uses: smartcontractkit/.github/actions/release-tag-check@c5c4a8186da4218cff6cac8184e47dd3dec69ba3 # v0.1.0
env:
# Match semver git tags with a "contracts-" prefix.
RELEASE_REGEX: '^contracts-v[0-9]+\.[0-9]+\.[0-9]+$'
PRE_RELEASE_REGEX: '^contracts-v[0-9]+\.[0-9]+\.[0-9]+-(.+)$'
# Get the version by stripping the "contracts-v" prefix.
VERSION_PREFIX: "contracts-v"
- name: Check release tag (ccip)
id: release-tag-check-ccip
uses: smartcontractkit/.github/actions/release-tag-check@c5c4a8186da4218cff6cac8184e47dd3dec69ba3 # v0.1.0
env:
# Match semver git tags with a "contracts-ccip/" prefix.
RELEASE_REGEX: '^contracts-ccip/v[0-9]+\.[0-9]+\.[0-9]+$'
PRE_RELEASE_REGEX: '^contracts-ccip/v[0-9]+\.[0-9]+\.[0-9]+-(.+)$'
# Get the version by stripping the "contracts-v" prefix.
VERSION_PREFIX: "contracts-ccip/v"
# CCIP release detected but:
# - contracts/package.json needs to be copied from: contracts/release/ccip/package.json
# - contracts/README.md needs to be copied from: contracts/release/ccip/README.md
# This should all happen before a CCIP contracts tag is published.
- name: Fail if CCIP files not updated
if: ${{ steps.release-tag-check-ccip.outputs.is-release == 'true' }}
shell: bash
run: |
error_msg="CCIP release detected but contracts/package.json or contracts/README.md is not up to date. Copy contracts/release/ccip/package.json and contracts/release/ccip/README.md to contracts/ and re-trigger workflow."
shasum_package_1=$(sha256sum contracts/package.json | awk '{print $1}')
shasum_package_2=$(sha256sum contracts/release/ccip/package.json | awk '{print $1}')
shasum_readme_1=$(sha256sum contracts/README.md | awk '{print $1}')
shasum_readme_2=$(sha256sum contracts/release/ccip/README.md | awk '{print $1}')
if [[ $shasum_package_1 != $shasum_package_2 || $shasum_readme_1 != $shasum_readme_2 ]]; then
echo "::error::${error_msg}"
exit 1
fi
prepublish-test:
needs: [changes, tag-check]
if: needs.changes.outputs.changes == 'true' || needs.tag-check.outputs.is-pre-release == 'true'
if: needs.changes.outputs.changes == 'true' || (needs.tag-check.outputs.is-pre-release-core == 'true' || needs.tag-check.outputs.is-pre-release-ccip == 'true')
name: Prepublish Test
runs-on: ubuntu-latest
steps:
Expand All @@ -76,9 +106,10 @@ jobs:
working-directory: contracts
run: pnpm prepublishOnly

# TODO: Confirm if this job is needed for CCIP contracts releases.
native-compile:
needs: [changes, tag-check]
if: needs.changes.outputs.changes == 'true' || needs.tag-check.outputs.is-release == 'true' || needs.tag-check.outputs.is-pre-release == 'true'
if: needs.changes.outputs.changes == 'true' || needs.tag-check.outputs.is-release-core == 'true' || needs.tag-check.outputs.is-pre-release-core == 'true'
name: Native Compilation
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -176,7 +207,7 @@ jobs:
name: Publish Beta NPM
environment: publish-contracts
needs: [tag-check, changes, lint, prettier, native-compile, prepublish-test]
if: needs.tag-check.outputs.is-pre-release == 'true'
if: needs.tag-check.outputs.is-pre-release-core == 'true' || needs.tag-check.outputs.is-pre-release-ccip == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
Expand All @@ -189,13 +220,29 @@ jobs:

- name: Version package.json
working-directory: contracts
shell: bash
env:
IS_PRE_RELEASE_CORE: ${{ needs.tag-check.outputs.is-pre-release-core }}
IS_PRE_RELEASE_CCIP: ${{ needs.tag-check.outputs.is-pre-release-ccip }}
PRE_RELEASE_VERSION_CORE: ${{ needs.tag-check.outputs.pre-release-version-core }}
PRE_RELEASE_VERSION_CCIP: ${{ needs.tag-check.outputs.pre-release-version-ccip }}
run: |
echo "Bumping version to ${{ needs.tag-check.outputs.pre-release-version }}"
pnpm version ${{ needs.tag-check.outputs.pre-release-version }} --no-git-tag-version --no-commit-hooks --no-git-checks
version=""
if [[ $IS_PRE_RELEASE_CORE == 'true' ]]; then
version="${PRE_RELEASE_VERSION_CORE}"
elif [[ $IS_PRE_RELEASE_CCIP == 'true' ]]; then
version="${PRE_RELEASE_VERSION_CCIP}"
else
echo "::error::No pre-release version found."
exit 1
fi
echo "Bumping version to ${version}"
pnpm version "${version}" --no-git-tag-version --no-commit-hooks --no-git-checks
- name: Publish to NPM (beta)
uses: smartcontractkit/.github/actions/ci-publish-npm@4b0ab756abcb1760cb82e1e87b94ff431905bffc # ci-publish-npm@0.4.0
with:
# TODO: confirm if this has perms to publish to @chainlink/contracts-ccip.
npm-token: ${{ secrets.NPM_TOKEN }}
create-github-release: false
publish-command: "pnpm publish-beta --no-git-checks"
Expand All @@ -205,7 +252,7 @@ jobs:
name: Publish Prod NPM
environment: publish-contracts
needs: [tag-check, changes, lint, prettier, native-compile, prepublish-test]
if: needs.tag-check.outputs.is-release == 'true'
if: needs.tag-check.outputs.is-release-core == 'true' || needs.tag-check.outputs.is-release-ccip == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -220,16 +267,32 @@ jobs:

- name: Validate version
working-directory: contracts
shell: bash
env:
IS_RELEASE_CORE: ${{ needs.tag-check.outputs.is-release-core }}
IS_RELEASE_CCIP: ${{ needs.tag-check.outputs.is-release-ccip }}
RELEASE_VERSION_CORE: ${{ needs.tag-check.outputs.release-version-core }}
RELEASE_VERSION_CCIP: ${{ needs.tag-check.outputs.release-version-ccip }}
run: |
PACKAGE_JSON_VERSION="$(cat package.json | jq -r '.version')"
if [ "$PACKAGE_JSON_VERSION" != "${{ needs.tag-check.outputs.release-version }}" ]; then
echo "::error version mismatch: package.json version ($PACKAGE_JSON_VERSION) does not match version computed from tag ${{ needs.tag-check.outputs.release-version }}"
version=""
if [[ $IS_RELEASE_CORE == 'true' ]]; then
version="${RELEASE_VERSION_CORE}"
elif [[ $IS_RELEASE_CCIP == 'true' ]]; then
version="${RELEASE_VERSION_CCIP}"
else
echo "::error::No release version found."
exit 1
fi
package_json_version="$(jq -r '.version' package.json)"
if [[ "$PACKAGE_JSON_VERSION" != "${version}" ]]; then
echo "::error version mismatch: package.json version ($package_json_version) does not match version computed from tag ${version}"
exit 1
fi
- name: Publish to NPM (latest)
uses: smartcontractkit/.github/actions/ci-publish-npm@4b0ab756abcb1760cb82e1e87b94ff431905bffc # ci-publish-npm@0.4.0
with:
# TODO: confirm if this has perms to publish to @chainlink/contracts-ccip.
npm-token: ${{ secrets.NPM_TOKEN }}
create-github-release: false
publish-command: "pnpm publish-prod --no-git-checks"
Expand Down

0 comments on commit 61bfdf1

Please sign in to comment.