66 is-stack-release :
77 type : boolean
88 description : Should we tag the current version as a stack release?
9+ required : true
10+ default : false
11+ dry-run :
12+ type : boolean
13+ description : " Should we run in dry-run mode?"
14+ required : true
915 default : false
1016
1117permissions :
12- contents : write
13-
14- env :
15- GH_TOKEN : ${{ github.token }}
18+ contents : write # needed to push the tag and create the release
1619
1720jobs :
1821 release :
1922 runs-on : ubuntu-latest
2023 steps :
2124 - uses : actions/checkout@v3
25+ with :
26+ fetch-depth : 0
2227 - uses : elastic/apm-pipeline-library/.github/actions/setup-git@current
2328 - uses : elastic/apm-pipeline-library/.github/actions/setup-npmrc@current
2429 with :
@@ -27,30 +32,31 @@ jobs:
2732 vault-role-id : ${{ secrets.VAULT_ROLE_ID }}
2833 vault-secret-id : ${{ secrets.VAULT_SECRET_ID }}
2934 - run : npm ci # runs npm prepublish
30- - name : Bump the version
31- run : |
32- echo "VERSION=$(npm version)" >> $GITHUB_ENV
33- echo "NPM_PACKAGE=$(jq '.name' package.json) >> $GITHUB_ENV
34- - run : git push --tags
3535 - uses : ./.github/actions/setup-totp
3636 with :
3737 vault-url : ${{ secrets.VAULT_ADDR }}
3838 vault-role-id : ${{ secrets.VAULT_ROLE_ID }}
3939 vault-secret-id : ${{ secrets.VAULT_SECRET_ID }}
40- - name : NPM Publish
41- run : npm publish --otp=${TOTP_CODE}
40+ - run : npx semantic-release --dry-run="${DRY_RUN}"
41+ env :
42+ DRY_RUN : ${{ github.event.inputs.dry-run }}
43+ GITHUB_TOKEN : ${{ github.token }}
44+
45+ - name : Get version and package name
46+ if : ${{ !github.event.inputs.dry-run }}
47+ run : |
48+ echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
49+ echo "NPM_PACKAGE=$(jq -r '.name' package.json) >> $GITHUB_ENV
50+
4251 - name : Create 'latest' dist-tag
52+ if : ${{ !github.event.inputs.dry-run }}
4353 run : npm dist-tag --otp=${TOTP_CODE} add "${NPM_PACKAGE}@${VERSION}" latest
54+
4455 - name : Create 'stack_release' dist-tag
45- if : ${{ github.event.inputs.is-stack-release }}
56+ if : ${{ !github.event.inputs.dry-run && github.event.inputs.is-stack-release }}
4657 run : npm dist-tag --otp=${TOTP_CODE} add "${NPM_PACKAGE}@${VERSION}" stack_release
47- - name : Create Draft Release Notes
48- run : >-
49- gh release create "${VERSION}"
50- --title="${VERSION}"
51- --generate-notes
52- --draft
53- - if : always()
58+
59+ - if : ${{ always() && !github.event.inputs.dry-run }}
5460 uses : elastic/apm-pipeline-library/.github/actions/notify-build-status@current
5561 with :
5662 vaultUrl : ${{ secrets.VAULT_ADDR }}
0 commit comments