Skip to content

Update synthetix in packages #247

Update synthetix in packages

Update synthetix in packages #247

name: Update synthetix in packages
on:
workflow_dispatch:
inputs:
synthetix_version:
description: 'Upstream `synthetix` repo version'
required: true
jobs:
update_version:
# run only on master branch
if: github.ref == 'refs/heads/master'
name: Update synthetix in packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- run: yarn npm whoami
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn install --immutable --immutable-cache
- name: Config git identity
run: |
git config --global user.email "[email protected]"
git config --global user.name "Synthetix CI"
- name: Update to the new synthetix version
run: |
TMP_PACKAGE_JSON=$(mktemp)
jq --arg synthetix_version "${{ github.event.inputs.synthetix_version }}" '.resolutions.synthetix = $synthetix_version' package.json > $TMP_PACKAGE_JSON
mv "$TMP_PACKAGE_JSON" package.json
yarn up "synthetix@${{ github.event.inputs.synthetix_version }}"
echo 'yarn workspace "@synthetixio/contracts" build'
yarn workspace "@synthetixio/contracts" build
# Synthetix version will bump only affected packages
for WORKSPACE_PACKAGE in $(git diff --name-only '**/package.json'); do
WORKSPACE_NAME=$(jq --raw-output '.name' < $WORKSPACE_PACKAGE)
yarn deps:version $WORKSPACE_NAME patch
done
# Commit changes in one go later
# git commit -am "synthetix@${{ github.event.inputs.synthetix_version }}" --allow-empty --no-verify
- run: yarn version apply --all
- run: yarn build
- name: Create git tag and commit changes
run: |
git diff --name-only '**/package.json' > /tmp/changed-packages.txt
cat /tmp/changed-packages.txt
echo -n > /tmp/commit-message.txt
echo "synthetix@${{ github.event.inputs.synthetix_version }}" > /tmp/commit-message.txt
echo 'Updated packages:' >> /tmp/commit-message.txt
for WORKSPACE_PACKAGE in $(cat /tmp/changed-packages.txt); do
WORKSPACE_NAME=$(jq --raw-output '.name' < $WORKSPACE_PACKAGE)
WORKSPACE_VERSION=$(jq --raw-output '.version' < $WORKSPACE_PACKAGE)
echo " - $WORKSPACE_NAME@$WORKSPACE_VERSION" >> /tmp/commit-message.txt
done
cat /tmp/commit-message.txt
git add .
git commit --allow-empty --no-verify --all --file /tmp/commit-message.txt
# We are currently not using tags in any way so not much sense pushing tags to the repo
# TODO: uncomment if we want to add tags
# for WORKSPACE_PACKAGE in $(cat /tmp/changed-packages.txt); do
# WORKSPACE_NAME=$(jq --raw-output '.name' < $WORKSPACE_PACKAGE)
# WORKSPACE_VERSION=$(jq --raw-output '.version' < $WORKSPACE_PACKAGE)
# git tag -a "$WORKSPACE_NAME@$WORKSPACE_VERSION" -m "$WORKSPACE_NAME@$WORKSPACE_VERSION"
# done
- name: Publish packages
run: yarn workspaces foreach --no-private npm publish --tolerate-republish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Push with tags
# - run: git push --follow-tags
# Push without tags
- run: git push
- name: Notify Synthetixio/futures-keepers
run: |
jq --null-input --compact-output --raw-output '{
ref: "develop"
}' > /tmp/futures-keepers.json
jq < /tmp/futures-keepers.json
curl --verbose --header "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST \
--data @/tmp/futures-keepers.json \
https://api.github.com/repos/Synthetixio/futures-keepers/actions/workflows/updateDependency.yml/dispatches
- name: Notify Synthetixio/perps-keepers
run: |
jq --null-input --compact-output --raw-output '{
ref: "develop"
}' > /tmp/perps-keepers.json
jq < /tmp/perps-keepers.json
curl --verbose --header "Authorization: token ${{ secrets.GH_TOKEN_DAPPS }}" --request POST \
--data @/tmp/perps-keepers.json \
https://api.github.com/repos/Synthetixio/perps-keepers/actions/workflows/updateDependency.yml/dispatches