Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f3ab2cff
authored
Jul 27, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: enhance GitCode release workflow to handle bootstrap and matrix assets
parent
6d57d250
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
13 deletions
+63
-13
.github/workflows/sync-release-to-gitcode.yml
+63
-13
No files found.
.github/workflows/sync-release-to-gitcode.yml
View file @
f3ab2cff
...
...
@@ -32,6 +32,8 @@ jobs:
release_prerelease
:
${{ steps.release.outputs.prerelease }}
bootstrap_asset
:
${{ steps.release.outputs.bootstrap_asset }}
release_asset_matrix
:
${{ steps.release.outputs.asset_matrix }}
has_bootstrap_asset
:
${{ steps.release.outputs.has_bootstrap_asset }}
has_matrix_assets
:
${{ steps.release.outputs.has_matrix_assets }}
steps
:
-
name
:
Wait for GitHub release workflows
if
:
${{ github.event_name == 'push' }}
...
...
@@ -90,6 +92,8 @@ jobs:
id
:
release
env
:
GH_TOKEN
:
${{ secrets.GITHUB_TOKEN }}
GITCODE_REPOSITORY
:
${{ vars.GITCODE_REPOSITORY }}
GITCODE_TOKEN
:
${{ secrets.GITCODE_TOKEN }}
RELEASE_TAG
:
${{ inputs.tag_name || github.ref_name }}
run
:
|
set -euo pipefail
...
...
@@ -124,24 +128,70 @@ jobs:
find release-assets -maxdepth 1 -type f -print | sort
bootstrap_asset
="$(
local_assets
="$(
find release-assets -maxdepth 1 -type f -printf '%s\t%f\n' \
| sort -n -k1,1 \
|
head -n 1
\
|
cut -f2-
|
cut -f2-
\
|
jq -Rsc 'split("\n") | map(select(length > 0))'
)"
asset_matrix="$(
find release-assets -maxdepth 1 -type f -printf '%f\n' \
| sort \
| jq -Rsc --arg bootstrap "$bootstrap_asset" \
'split("\n") | map(select(length > 0 and . != $bootstrap))'
gitcode_release_json="$(mktemp)"
gitcode_release_status="$(
curl -L -sS -o "$gitcode_release_json" -w "%{http_code}" \
-H "PRIVATE-TOKEN: $GITCODE_TOKEN" \
-H "Accept: application/json" \
"https://api.gitcode.com/api/v5/repos/$GITCODE_REPOSITORY/releases/tags/$RELEASE_TAG"
)"
case "$gitcode_release_status" in
200)
release_exists=true
existing_assets="$(jq -c '[.assets[]?.name]' "$gitcode_release_json")"
;;
404)
release_exists=false
existing_assets='[]'
;;
*)
echo "::error::Failed to inspect GitCode release. Response code: $gitcode_release_status"
cat "$gitcode_release_json"
exit 1
;;
esac
missing_assets="$(
jq -cn \
--argjson local_assets "$local_assets" \
--argjson existing_assets "$existing_assets" \
'$local_assets - $existing_assets'
)"
jq -rn \
--argjson local_assets "$local_assets" \
--argjson missing_assets "$missing_assets" \
'$local_assets - $missing_assets | .[] | "Skipping existing GitCode asset: \(.)"'
if [[ "$release_exists" == "false" ]]; then
bootstrap_asset="$(jq -r '.[0] // ""' <<< "$missing_assets")"
asset_matrix="$(jq -c '.[1:]' <<< "$missing_assets")"
else
bootstrap_asset=""
asset_matrix="$missing_assets"
fi
if [[ -n "$bootstrap_asset" ]]; then
has_bootstrap_asset=true
else
has_bootstrap_asset=false
fi
has_matrix_assets="$(jq -r 'length > 0' <<< "$asset_matrix")"
delimiter="release-body-$(openssl rand -hex 16)"
{
echo "tag=$RELEASE_TAG"
echo "bootstrap_asset=$bootstrap_asset"
echo "asset_matrix=$asset_matrix"
echo "has_bootstrap_asset=$has_bootstrap_asset"
echo "has_matrix_assets=$has_matrix_assets"
echo "body<<$delimiter"
# sync_to_gitcode embeds this input in a single-quoted shell string.
# Replace ASCII apostrophes so release notes cannot break its script.
...
...
@@ -158,10 +208,10 @@ jobs:
if-no-files-found
:
error
retention-days
:
1
gitcode-release-
metadata
:
name
:
Publish GitCode release metadata
gitcode-release-
bootstrap
:
name
:
Create GitCode release
needs
:
prepare-release-assets
if
:
${{ vars.GITCODE_REPOSITORY != '' }}
if
:
${{ vars.GITCODE_REPOSITORY != ''
&& needs.prepare-release-assets.outputs.has_bootstrap_asset == 'true'
}}
uses
:
nvdacn/sync_to_gitcode/.github/workflows/CreateReleaseOnGitCode.yaml@18b70112d0e62260bc54085028e5510bbc6323b2
with
:
artifact_name
:
gitcode-release-assets
...
...
@@ -178,8 +228,8 @@ jobs:
name
:
Publish GitCode asset (${{ matrix.file_name }})
needs
:
-
prepare-release-assets
-
gitcode-release-
metadata
if
:
${{
vars.GITCODE_REPOSITORY != '
' }}
-
gitcode-release-
bootstrap
if
:
${{
always() && vars.GITCODE_REPOSITORY != '' && needs.prepare-release-assets.result == 'success' && (needs.gitcode-release-bootstrap.result == 'success' || needs.gitcode-release-bootstrap.result == 'skipped') && needs.prepare-release-assets.outputs.has_matrix_assets == 'true
' }}
strategy
:
fail-fast
:
false
max-parallel
:
4
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment