Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ jobs:
attestations: write
outputs:
version: ${{ steps.package-version.outputs.version }}
npm-tag: ${{ steps.release-kind.outputs.npm-tag }}
prerelease: ${{ steps.release-kind.outputs.prerelease }}
steps:
- name: Reject disallowed branch
if: >-
${{ !startsWith(github.ref, 'refs/heads/development/')
&& !startsWith(github.ref, 'refs/heads/hotfix/') }}
&& !startsWith(github.ref, 'refs/heads/hotfix/')
&& !startsWith(github.ref, 'refs/heads/epic/') }}
env:
REF_NAME: ${{ github.ref_name }}
run: |
echo "::error::Releases must run from a development/* or" \
"hotfix/* branch (got $REF_NAME)"
echo "::error::Releases must run from a development/*," \
"hotfix/* or epic/* branch (got $REF_NAME)"
exit 1

- name: Checkout code
Expand All @@ -39,6 +42,24 @@ jobs:
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Pick npm dist-tag
id: release-kind
env:
REF_NAME: ${{ github.ref_name }}
VERSION: ${{ steps.package-version.outputs.version }}
run: |
case "${VERSION%%+*}" in
*-*) prerelease=true; npm_tag=prerelease ;;
*) prerelease=false; npm_tag=latest ;;
esac
if [[ "$REF_NAME" == epic/* && "$prerelease" != true ]]; then
echo "::error::An epic/* branch releases prerelease" \
"versions only (got $VERSION)"
exit 1
fi
echo "npm-tag=$npm_tag" >> "$GITHUB_OUTPUT"
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"

- name: Fail if release already exists
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -105,11 +126,12 @@ jobs:
- name: Publish to npm with provenance
env:
VERSION: ${{ needs.build.outputs.version }}
NPM_TAG: ${{ needs.build.outputs.npm-tag }}
run: |
if [ -n "$(npm view "@scality/cloudserverclient@$VERSION" version 2>/dev/null)" ]; then
echo "::notice::@scality/cloudserverclient@$VERSION already on npm; skipping"
else
npm publish *.tgz --provenance --tag latest
npm publish *.tgz --provenance --tag "$NPM_TAG"
fi

publish-github:
Expand All @@ -135,11 +157,12 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build.outputs.version }}
NPM_TAG: ${{ needs.build.outputs.npm-tag }}
run: |
if [ -n "$(npm view "@scality/cloudserverclient@$VERSION" version 2>/dev/null)" ]; then
echo "::notice::@scality/cloudserverclient@$VERSION already on GitHub Packages; skipping"
else
npm publish *.tgz --tag latest
npm publish *.tgz --tag "$NPM_TAG"
fi

create-release:
Expand All @@ -157,6 +180,7 @@ jobs:
tag_name: ${{ needs.build.outputs.version }}
name: Release ${{ needs.build.outputs.version }}
target_commitish: ${{ github.sha }}
prerelease: ${{ needs.build.outputs.prerelease == 'true' }}
generate_release_notes: true
append_body: true
body: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scality/cloudserverclient",
"version": "1.0.13",
"version": "1.0.14-bnaas.1",
"engines": {
"node": ">=20"
},
Expand Down
Loading