Skip to content

Commit e572764

Browse files
authored
feat(github_release): add support for release assets (#68)
- Build release assets in build_local job if npm script exists - Persist assets to workspace - Upload assets to GitHub release
1 parent 0ec83e8 commit e572764

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎src/jobs/build_local.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,20 @@ steps:
3636
- run:
3737
name: Save docker image to workspace
3838
command: docker save -o /tmp/docker-image.tar ${DOCKER_ORG:-mojaloop}/$CIRCLE_PROJECT_REPONAME:local
39+
- run:
40+
name: Build Release Assets
41+
command: |
42+
if npm run 2>/dev/null | grep -q "release:assets"; then
43+
echo "Found release:assets script, building assets..."
44+
mkdir -p /tmp/release-assets
45+
npm run release:assets -- /tmp/release-assets
46+
echo "Assets built:"
47+
ls -la /tmp/release-assets
48+
else
49+
echo "No release:assets script found, skipping..."
50+
fi
3951
- persist_to_workspace:
4052
root: /tmp
4153
paths:
4254
- ./docker-image.tar
55+
- ./release-assets

‎src/jobs/github_release.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ steps:
2121
sudo apt-get update && sudo apt-get install -y git
2222
- gh/install
2323
- checkout
24+
- attach_workspace:
25+
at: /tmp
2426
- configure_git
2527
- run:
2628
name: Fetch updated release branch
@@ -68,6 +70,22 @@ steps:
6870
name: Create Release
6971
command: |
7072
gh release create "v${RELEASE_TAG}" --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md
73+
- run:
74+
name: Upload Release Assets
75+
command: |
76+
RELEASE_ASSETS_DIR="/tmp/release-assets"
77+
if [ -d "$RELEASE_ASSETS_DIR" ] && [ "$(ls -A $RELEASE_ASSETS_DIR 2>/dev/null)" ]; then
78+
echo "Found release assets in workspace:"
79+
ls -la "$RELEASE_ASSETS_DIR"
80+
for asset in "$RELEASE_ASSETS_DIR"/*; do
81+
if [ -f "$asset" ]; then
82+
echo "Uploading: $(basename "$asset")"
83+
gh release upload "v${RELEASE_TAG}" "$asset" --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
84+
fi
85+
done
86+
else
87+
echo "No release assets found in workspace, skipping..."
88+
fi
7189
- when:
7290
condition: << parameters.slack >>
7391
steps:

0 commit comments

Comments
 (0)