Skip to content

Commit

Permalink
Fixes release.yaml
Browse files Browse the repository at this point in the history
The long-polling loop performed until a package is published called `yarn info` instead of `yarn npm info`
  • Loading branch information
jkilzi committed Aug 24, 2023
1 parent d8b57ae commit 203646c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:

- name: Lookup for workspaces to be published
run: |
declare -a workspaces=()
for pkg in `ls -1 libs/*/package.json`; do
if [[ "$(jq '.publishConfig.access == "public"' ${pkg})" == "true" ]]; then
workspaces+=("${pkg:5:-13}")
declare -a LIBS=()
for pkg in libs/*/package.json; do
if [[ "$(jq '.publishConfig.access == "public"' "${pkg}")" = "true" ]]; then
LIBS+=("${pkg:5:-13}")
fi
done
(IFS=,; printf 'The following workspaces will be published: [%s]' "${workspaces[*]}")
echo "WORKSPACES=${workspaces}" >> $GITHUB_ENV
echo "LIBS=${LIBS[@]}" >> $GITHUB_ENV
(IFS=,; printf 'The following workspaces will be published: [%s]\n' "${LIBS[*]}")
- name: Configuring git
run: |
Expand All @@ -51,11 +51,13 @@ jobs:

- name: Bump workspaces to ${{ github.ref_name }}
run: |
for ws in "${WORKSPACES[@]}"; do
yarn workspace @openshift-assisted/${ws} version ${GITHUB_REF_NAME:1}
# The above command adds a `stableVersion` field after bumping. Removing it as it's buggy.
# See: https://github.com/yarnpkg/berry/issues/4328
echo "$(jq 'del(.stableVersion)' libs/${ws}/package.json)" > libs/${ws}/package.json
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
Expand All @@ -66,18 +68,24 @@ jobs:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
yarn config set npmScopes.openshift-assisted.npmAuthToken $NPM_AUTH_TOKEN
for ws in "${WORKSPACES[@]}"; do
yarn workspace @openshift-assisted/${ws} npm publish
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 info @openshift-assisted/${ws} &> /dev/null; do
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: |
git add libs/ui-lib/package.json libs/locales/package.json 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
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
1 change: 0 additions & 1 deletion apps/assisted-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"dependencies": {
"@openshift-assisted/locales": "workspace:*",
"@openshift-assisted/ui-lib": "workspace:*",
"@openshift-console/dynamic-plugin-sdk": "0.0.3",
"@patternfly/patternfly": "^4.222.4",
Expand Down
4 changes: 2 additions & 2 deletions libs/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@openshift-assisted/types",
"version": "1.0.0",
"packageManager": "[email protected]",
"type": "module",
"exports": {
Expand Down Expand Up @@ -39,5 +38,6 @@
"@types/js-yaml": "^4.0.1",
"js-yaml": "^4.1.0",
"sw2dts": "^2.6.3"
}
},
"version": "1.0.0"
}
4 changes: 2 additions & 2 deletions libs/ui-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"@openshift-assisted/locales": "workspace:^",
"@openshift-assisted/types": "workspace:^",
"@openshift-assisted/locales": "workspace:*",
"@openshift-assisted/types": "workspace:*",
"axios-case-converter": "^0.11.1",
"camel-case": "^4.1.2",
"cidr-tools": "^4.3.0",
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ __metadata:
resolution: "@openshift-assisted/assisted-ui@workspace:apps/assisted-ui"
dependencies:
"@openshift-assisted/eslint-config-assisted-ui": "workspace:*"
"@openshift-assisted/locales": "workspace:*"
"@openshift-assisted/ui-lib": "workspace:*"
"@openshift-console/dynamic-plugin-sdk": 0.0.3
"@patternfly/patternfly": ^4.222.4
Expand Down Expand Up @@ -439,7 +438,7 @@ __metadata:
languageName: unknown
linkType: soft

"@openshift-assisted/locales@workspace:*, @openshift-assisted/locales@workspace:^, @openshift-assisted/locales@workspace:libs/locales":
"@openshift-assisted/locales@workspace:*, @openshift-assisted/locales@workspace:libs/locales":
version: 0.0.0-use.local
resolution: "@openshift-assisted/locales@workspace:libs/locales"
dependencies:
Expand All @@ -461,7 +460,7 @@ __metadata:
languageName: unknown
linkType: soft

"@openshift-assisted/types@workspace:^, @openshift-assisted/types@workspace:libs/types":
"@openshift-assisted/types@workspace:*, @openshift-assisted/types@workspace:libs/types":
version: 0.0.0-use.local
resolution: "@openshift-assisted/types@workspace:libs/types"
dependencies:
Expand Down Expand Up @@ -491,8 +490,8 @@ __metadata:
resolution: "@openshift-assisted/ui-lib@workspace:libs/ui-lib"
dependencies:
"@openshift-assisted/eslint-config-assisted-ui": "workspace:^"
"@openshift-assisted/locales": "workspace:^"
"@openshift-assisted/types": "workspace:^"
"@openshift-assisted/locales": "workspace:*"
"@openshift-assisted/types": "workspace:*"
"@tsconfig/recommended": ^1.0.2
"@types/file-saver": ^2.0.1
"@types/human-date": ^1.4.0
Expand Down

0 comments on commit 203646c

Please sign in to comment.