|
1 | 1 | #!/bin/bash -xv
|
2 | 2 |
|
3 |
| - # Removes "v" prefix |
4 |
| -version=${GITHUB_REF_NAME:1} |
5 |
| - |
6 |
| -# Major of the version being handled by the current workflow |
| 3 | +# Get the git tag that triggered the workflow build |
| 4 | +workflow_version=${GITHUB_REF_NAME:1} # Removed the "v" prefix |
| 5 | +# Get version major being handled by the current workflow |
7 | 6 | workflow_major=$(echo $version | cut -d. -f1)
|
8 |
| - |
9 | 7 | workflow_track="latest-v${workflow_major}.x"
|
10 | 8 |
|
11 |
| -# Major of the version published under the current "latest" npm tag |
12 |
| -latest_major=$(npm view cross-fetch@latest version | cut -d. -f1) |
| 9 | +# Get latest version on npm registry |
| 10 | +latest_version=$(npm view cross-fetch@latest version) |
| 11 | +# Get version major published under the current "latest" npm tag |
| 12 | +latest_major=$(echo $latest_version | cut -d. -f1) |
13 | 13 |
|
14 | 14 |
|
15 |
| -# If it's test prerelease, we just want to test the release workflow (dry run it!) |
16 |
| -if [[ "$version" == *"-test."* ]]; then |
| 15 | +# If it's a test prerelease, we just want to test the release workflow (dry run it!) |
| 16 | +if [[ "$workflow_version" == *"-test."* ]]; then |
17 | 17 | npm publish --tag $workflow_track --dry-run && \
|
18 | 18 | exit 0
|
19 | 19 | fi
|
20 | 20 |
|
21 | 21 | npm publish --tag $workflow_track
|
22 | 22 |
|
23 | 23 | if [[ "$workflow_major" == "$latest_major" ]]; then
|
24 |
| - npm dist-tag add cross-fetch@$version latest |
| 24 | + npm dist-tag add cross-fetch@$workflow_version latest |
25 | 25 | fi
|
26 | 26 |
|
27 | 27 | if [[ "$workflow_major" == "$(($latest_major + 1))" ]]; then
|
28 |
| - npm dist-tag add cross-fetch@$version next |
| 28 | + npm dist-tag add cross-fetch@$workflow_version next |
29 | 29 | fi
|
0 commit comments