Skip to content

Commit 3edd312

Browse files
Fix workflow issue where latest version was not found
1 parent 01d7a13 commit 3edd312

2 files changed

Lines changed: 38 additions & 20 deletions

File tree

.github/workflows/refresh-release.sh

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# respective major tag (e.g. v2) was pushed.
55

66
github_token=""
7+
version_override=""
78
repo_desc="\`github-pages\` Publish Action"
89

910
function fail() {
@@ -14,6 +15,7 @@ function fail() {
1415
for param in "${@}"; do
1516
case "${param}" in
1617
'--github-token='*) github_token="${param#*=}";;
18+
'--version='*) version_override="${param#*=}";;
1719
*) fail "Unknown argument '${param}'.";;
1820
esac
1921
done
@@ -22,25 +24,30 @@ if [ ${#github_token} -lt 10 ]; then
2224
fail "GitHub token (--github-token) is invalid."
2325
fi
2426

25-
echo "- Querying latest Retype release from NuGet.org..."
26-
result="$(curl -s https://api.nuget.org/v3/registration5-gz-semver2/retypeapp/index.json | gunzip)" || \
27-
fail "Unable to fetch retype package page from nuget.org website as a gzipped response."
28-
29-
# Wrap a node script to parse the response JSON string.
30-
nodescp="const stdin = process.stdin;
31-
let data='';
32-
stdin.setEncoding('utf8');
33-
stdin.on('data', function (chunk) {
34-
data += chunk;
35-
});
36-
stdin.on('end', function() {
37-
var objdata = JSON.parse(data);
38-
var pkmeta=objdata.items[0];
39-
console.log(pkmeta.items[pkmeta.items.length-1].catalogEntry.version);
40-
});
41-
stdin.on('error', console.error);"
42-
43-
latest="$(echo "${result}" | node -e "${nodescp}")" || fail "Unable parse latest version from NuGet API Json response."
27+
if [ -n "${version_override}" ]; then
28+
echo "- Using version provided by orchestration: ${version_override}"
29+
latest="${version_override}"
30+
else
31+
echo "- Querying latest Retype release from NuGet.org..."
32+
result="$(curl -s https://api.nuget.org/v3/registration5-gz-semver2/retypeapp/index.json | gunzip)" || \
33+
fail "Unable to fetch retype package page from nuget.org website as a gzipped response."
34+
35+
# Wrap a node script to parse the response JSON string.
36+
nodescp="const stdin = process.stdin;
37+
let data='';
38+
stdin.setEncoding('utf8');
39+
stdin.on('data', function (chunk) {
40+
data += chunk;
41+
});
42+
stdin.on('end', function() {
43+
var objdata = JSON.parse(data);
44+
var pkmeta=objdata.items[0];
45+
console.log(pkmeta.items[pkmeta.items.length-1].catalogEntry.version);
46+
});
47+
stdin.on('error', console.error);"
48+
49+
latest="$(echo "${result}" | node -e "${nodescp}")" || fail "Unable parse latest version from NuGet API Json response."
50+
fi
4451

4552
if [ -z "${latest}" ]; then
4653
fail "Unable to extract latest version number from NuGet website."
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Publish new Release
22
on:
33
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Retype version to release (e.g., 4.1.0-preview). If not provided, queries NuGet.org for the latest version.'
7+
required: false
8+
type: string
9+
default: ''
410
jobs:
511
publish:
612
name: Sync tags with latest Retype release
@@ -9,4 +15,9 @@ jobs:
915
- uses: actions/checkout@v6
1016
- name: Update and Release
1117
shell: bash
12-
run: .github/workflows/refresh-release.sh --github-token="${{ secrets.GITHUB_TOKEN }}"
18+
run: |
19+
args="--github-token=${{ secrets.GITHUB_TOKEN }}"
20+
if [ -n "${{ inputs.version }}" ]; then
21+
args+=" --version=${{ inputs.version }}"
22+
fi
23+
.github/workflows/refresh-release.sh ${args}

0 commit comments

Comments
 (0)