diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab1ccf62a..ef7fb0506 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: Main Workflow on: - push: {} + pull_request: + branches: + - main + - master jobs: build: @@ -17,9 +20,13 @@ jobs: - run: npm run lint - run: npx lerna run build - run: npx lerna run test - - run: git config --global user.email "you@example.com" && git config --global user.name "Your Name" - - run: npx lerna version 0.0.0-$(git rev-parse --short HEAD) --exact --no-push -y - - run: npx lerna publish from-package --npm-tag dev --skip-git -y + + # publish + - run: git config --global user.email "ci@cc.snxdao.io" && git config --global user.name "Synthetix CI" + - run: git fetch origin ${{ github.head_ref }} + - run: echo $(git rev-parse --short origin/${{ github.head_ref }}) + #- run: npx lerna version 0.0.0-$(git rev-parse --short origin/${{ github.head_ref }}) --exact --no-push -y + - run: npx lerna exec npm version 0.0.0-$(git rev-parse --short origin/${{ github.head_ref }}) + - run: npx lerna exec npm publish -- --tag dev env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - run: echo "npm pushed to 0.0.0-$(git rev-parse --short HEAD)" diff --git a/.github/workflows/updateDependency.yml b/.github/workflows/updateDependency.yml index bd8cf6b29..3a76d04ab 100644 --- a/.github/workflows/updateDependency.yml +++ b/.github/workflows/updateDependency.yml @@ -1,9 +1,14 @@ name: Publish Library on: - repository_dispatch: - types: update-synthetix - workflow_dispatch: {} + workflow_dispatch: + inputs: + synthetix_version: + description: 'Upstream `synthetix` repo version (leave empty if no update)' + required: false + monorepo_version: + description: 'New Monorepo Version (ex. 2.50.0-alpha) (leave empty to "bump")' + required: false jobs: update_version: @@ -15,14 +20,19 @@ jobs: with: node-version: '14' registry-url: 'https://registry.npmjs.org' - - name: Update @synthetixio/contracts-interface + - name: resolve version run: | - echo "Update @synthetixio/contracts-interface with synthetix@${{ github.event.client_payload.version }}" - cd packages/contracts-interface && npm install synthetix@${{ github.event.client_payload.version }} --save-exact - - name: Commit changes + export theversion="bump" + if [ -n "${{ github.event.inputs.monorepo_version }}" ]; then export theversion="${{ github.event.inputs.monorepo_version }}"; fi + echo "Resolved version $theversion" + echo "new_version=$theversion" >> $GITHUB_ENV + - name: Update @synthetixio/contracts-interface + if: github.event.inputs.synthetix_version run: | - git config --global user.email "team@synthetix.io" && git config --global user.name "Synthetix Team" - git commit -am 'synthetix@${{ github.event.client_payload.version }}' + echo "Update @synthetixio/contracts-interface with synthetix@${{ github.event.inputs.synthetix_version }}" + cd packages/contracts-interface && npm install synthetix@${{ github.event.inputs.synthetix_version }} --save-exact + git config --global user.email "ci@cc.snxdao.io" && git config --global user.name "Synthetix CI" + git commit -am "synthetix@${{ github.event.inputs.synthetix_version }}" - name: Lints and build run: | npm ci @@ -31,7 +41,7 @@ jobs: npm run build npm run test-all - name: Update packages version - run: lerna version ${{ github.event.client_payload.version }} --exact --yes + run: lerna version ${{ env.new_version }} --exact --yes - name: Publish packages run: lerna publish from-package --yes env: @@ -40,5 +50,5 @@ jobs: run: git push - name: Notify dApps run: | - curl -H "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST --data "{\"event_type\": \"update-dependency\", \"client_payload\": {\"version\": \"${{ github.event.client_payload.version }}\"}}" https://api.github.com/repos/Synthetixio/staking/dispatches - curl -H "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST --data "{\"event_type\": \"update-dependency\", \"client_payload\": {\"version\": \"${{ github.event.client_payload.version }}\"}}" https://api.github.com/repos/Kwenta/kwenta/dispatches + curl -H "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST --data "{\"event_type\": \"update-dependency\", \"client_payload\": {\"version\": \"${{ env.new_version }}\"}}" https://api.github.com/repos/Synthetixio/staking/dispatches + curl -H "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST --data "{\"event_type\": \"update-dependency\", \"client_payload\": {\"version\": \"${{ env.new_version }}\"}}" https://api.github.com/repos/Kwenta/kwenta/dispatches