Publish Packages #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Packages | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: 'Comma-separated packages names' | |
required: true | |
version: | |
description: 'Package version (defaults to `prerelease`)' | |
default: 'prerelease' | |
required: false | |
jobs: | |
update_version: | |
# run only on master branch | |
if: github.ref == 'refs/heads/master' | |
name: Publish Single Package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
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 "ci@snxdao.io" | |
git config --global user.name "Synthetix CI" | |
- run: yarn deps:version '${{ github.event.inputs.package }}' ${{ github.event.inputs.version }} | |
- 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 '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 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 |