diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f90868f..fa2ff8cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 }} @@ -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: @@ -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: @@ -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: | diff --git a/package.json b/package.json index 19d8a425..d0667dc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@scality/cloudserverclient", - "version": "1.0.13", + "version": "1.0.14-bnaas.1", "engines": { "node": ">=20" },