v2.34.1 #394
Workflow file for this run
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: Release a new version | |
on: | |
release: | |
types: | |
- published | |
env: | |
NODE_OPTIONS: '--max-old-space-size=8192' | |
jobs: | |
publish-to-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check workflow runs in a release branch | |
run: | | |
if [[ "${{ github.event.release.target_commitish }}" != *releases* ]]; then | |
echo "Expecting to be in a release branch, but we are in: ${{ github.event.release.target_commitish }}" | |
exit 1 | |
fi | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PUSH_TO_PROTECTED_BRANCH }} | |
ref: ${{ github.event.release.target_commitish }} | |
fetch-depth: 0 | |
- name: Lookup for workspaces to be published | |
run: | | |
declare -a LIBS=() | |
for pkg in libs/*/package.json; do | |
if [[ "$(jq '.publishConfig.access == "public"' "${pkg}")" = "true" ]]; then | |
LIBS+=("${pkg:5:-13}") | |
fi | |
done | |
echo "LIBS=${LIBS[@]}" >> $GITHUB_ENV | |
(IFS=,; printf 'The following workspaces will be published: [%s]\n' "${LIBS[*]}") | |
- name: Configuring git | |
run: | | |
git config user.name '${{ github.actor }}' | |
git config user.email '${{ github.actor }}@users.noreply.github.com' | |
- uses: actions/setup-node@v3 | |
with: | |
cache: yarn | |
node-version: ${{ vars.NODEJS_VERSION }} | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Bump workspaces to ${{ github.ref_name }} | |
run: | | |
for LIB in $(echo ${LIBS}); do | |
echo Bumping @openshift-assisted/"${LIB}" | |
# The next command adds a `stableVersion` field after bumping. | |
# We need to remove it because it's buggy. See: https://github.com/yarnpkg/berry/issues/4328 | |
yarn workspace @openshift-assisted/"${LIB}" version "${GITHUB_REF_NAME:1}" | |
jq 'del(.stableVersion)' libs/"${LIB}"/package.json > libs/"${LIB}"/package.tmp.json | |
mv libs/"${LIB}"/package.tmp.json libs/"${LIB}"/package.json | |
done | |
- name: Build | |
run: yarn build:all | |
- name: Publish workspaces to NPM | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
run: | | |
yarn config set npmScopes.openshift-assisted.npmAuthToken $NPM_AUTH_TOKEN | |
for LIB in $(echo ${LIBS}); do | |
printf 'Publishing @openshift-assisted/%s\n' "${LIB}" | |
yarn workspace @openshift-assisted/${LIB} npm publish | |
# Verify the package has been published before publishing another one. | |
until [[ "$(yarn npm info @openshift-assisted/${LIB} --fields version --json | jq -r '.version')" = "${GITHUB_REF_NAME:1}" ]]; do | |
printf '@openshift-assisted/%s has not ben published yet\n' "${LIB}" | |
sleep ${{ vars.NPM_PUBLISH_DELAY }} | |
echo "Retrying..." | |
done | |
done | |
- name: Update the repo | |
run: | | |
for LIB in $(echo ${LIBS}); do | |
git add libs/"${LIB}"/package.json | |
done | |
git add apps/assisted-ui/package.json | |
git commit -m "Version ${GITHUB_REF_NAME}" | |
git tag -f -a ${GITHUB_REF_NAME} -m "${GITHUB_REF_NAME}" | |
git push origin ${GITHUB_REF_NAME} --force | |
git push origin ${{ github.event.release.target_commitish }} --force |