File: 02-release-builds.sh

package info (click to toggle)
node-yarnpkg 4.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,752 kB
  • sloc: javascript: 38,953; ansic: 26,035; cpp: 7,247; sh: 2,829; makefile: 724; perl: 493
file content (38 lines) | stat: -rwxr-xr-x 1,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash

set -ex

THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_DIR="$THIS_DIR/../.."

if ! [[ -z $(git status --porcelain) ]]; then
  echo 'This command must be executed on a clean repository'
  exit 1
fi

RELEASE_ARGUMENTS=()

CLOSEST_TAG=$(git describe --tags --abbrev=0)
RELEASE_COMMIT=$(git rev-list -n 1 "$CLOSEST_TAG")

maybe_release_package() {
  if git describe --match "$1/*" $RELEASE_COMMIT >&/dev/null; then
    RELEASE_ARGUMENTS+=(--include "$1")
  fi
}

while read ident; do
  maybe_release_package "$ident"
done < <(yarn constraints query --json "workspace_ident(Cwd, Ident), \+ workspace_field(Cwd, 'private', 'true')" | jq -r .Ident)

if [[ ${#RELEASE_ARGUMENTS[@]} -eq 0 ]]; then
  exit 0
fi

YARN_NPM_PUBLISH_REGISTRY=https://npm.pkg.github.com yarn workspaces foreach \
  --verbose --all --topological --no-private "${RELEASE_ARGUMENTS[@]}" \
  npm publish --tolerate-republish

yarn workspaces foreach \
  --verbose --all --topological --no-private "${RELEASE_ARGUMENTS[@]}" \
  npm publish --tolerate-republish