diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a480b2a..83a55b7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -33,19 +33,6 @@ jobs: - run: yarn build - run: yarn lint - run: yarn test - - name: Require clean working directory - shell: bash - run: | - if ! git diff --exit-code; then - echo "Working tree dirty after building" - exit 1 - fi - # - name: Validate RC changelog - # if: ${{ startsWith(github.head_ref, 'release/') }} - # run: yarn auto-changelog validate --rc - # - name: Validate changelog - # if: ${{ !startsWith(github.head_ref, 'release/') }} - # run: yarn auto-changelog validate all-jobs-pass: name: All jobs pass runs-on: ubuntu-20.04 diff --git a/.github/workflows/check-package-version.yml b/.github/workflows/check-package-version.yml new file mode 100644 index 0000000..94d2af8 --- /dev/null +++ b/.github/workflows/check-package-version.yml @@ -0,0 +1,38 @@ +name: Check Package Version in PR + +on: + pull_request: + branches: + - main + paths: + - 'packages/snap/src/**' + +jobs: + check_version: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: 'create-main-branch' + run: 'git branch --track main origin/main' + + - name: Get version from main branch + id: get_version_main + run: echo "::set-output name=version::$(git show HEAD~1:package.json | grep '"version":' | cut -d '"' -f 4)" + + - name: Get version from PR branch + id: get_version_pr + run: echo "::set-output name=version::$(grep '"version":' package.json | cut -d '"' -f 4)" + + - name: Compare versions and prevent merging if the same + run: | + if [ "${{ steps.get_version_main.outputs.version }}" == "${{ steps.get_version_pr.outputs.version }}" ]; then + echo "Error: Versions in main branch and PR are the same - please upgrade version in PR." + exit 1 + else + echo "Versions are different, allowing merge" + echo "::set-output name=version_changed::true" + fi diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..ca1ba42 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,18 @@ +name: 'NPM Publish' +on: + release: + types: [published] + +jobs: + NPM-Publish: + permissions: + contents: read + id-token: write + + uses: celo-org/reusable-workflows/.github/workflows/npm-publish.yaml@v1.11.1 + with: + node-version: 16 + package-dir: 'packages/snap' + akeyless-api-gateway: https://api.gateway.akeyless.celo-networks-dev.org + akeyless-github-access-id: p-kf9vjzruht6l + akeyless-token-path: /static-secrets/apps-tooling-circle/npm-publish-token diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index e1ae1b0..0000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Publish Release - -on: - pull_request: - types: [closed] - -jobs: - publish-release: - permissions: - contents: write - if: | - github.event.pull_request.merged == true && - startsWith(github.event.pull_request.head.ref, 'release/') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - # We check out the release pull request's base branch, which will be - # used as the base branch for all git operations. - ref: ${{ github.event.pull_request.base.ref }} - - name: Get Node.js version - id: nvm - run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) - - uses: actions/setup-node@v2 - with: - node-version: ${{ steps.nvm.outputs.NODE_VERSION }} - - uses: MetaMask/action-publish-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Get Yarn cache directory - run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)" - id: yarn-cache-dir - - name: Get Yarn version - run: echo "::set-output name=YARN_VERSION::$(yarn --version)" - id: yarn-version - - name: Cache yarn dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} - key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }} - - run: yarn install --immutable - - run: yarn build:site - - name: Publish to GitHub Pages - uses: MetaMask/action-publish-gh-pages@v2 - with: - source-directory: packages/site/public - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/packages/snap/README.md b/packages/snap/README.md index 11a3b38..8250d4a 100644 --- a/packages/snap/README.md +++ b/packages/snap/README.md @@ -99,15 +99,17 @@ This example shows how one can use the snap to send a more generic transaction. ## Publishing a new version of the Snap. -In other to update the snap to publish a new change, Update the `version` tag in both `packages/snap/snap.config.js` and `packages/snap/package.json` to the same. Then from you console run the following commands. +In other to update the snap to publish a new change, Update the `version` tag in both `packages/snap/snap.config.js` and `packages/snap/package.json` to the same. -Note: You must be logged into NPM on your terminal as well as added to the celo organization on npm. +Next create a new Release: +You can do this by going to the "Releases" tab, then clicking the "Create a new release" button. -``` -cd packages/snap +Tag version: Specify the version number, such as v1.0.0 ( keep this consistent with those above ) +Release title: Provide a descriptive title for the release. +Describe the release: Add any release notes, changelog information, or details about what's included in this release. +Choose "Publish release" to create the release. -npm publish --access public -``` +Action should automatically trigger the job. ## Register a new coin type.