Skip to content

Commit

Permalink
Use semantic-release for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
reakaleek committed Sep 7, 2023
1 parent f81aa09 commit 2cacc54
Show file tree
Hide file tree
Showing 4 changed files with 19,464 additions and 10,028 deletions.
37 changes: 12 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ name: release
on:
workflow_dispatch:
inputs:
is-stack-release:
type: boolean
description: Should we tag the current version as a stack release?
dry-run:
description: "Should we run in dry-run mode?"
required: true
default: false
type: boolean

permissions:
contents: write

env:
GH_TOKEN: ${{ github.token }}
contents: write # needed to push the tag and create the release

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
- uses: elastic/apm-pipeline-library/.github/actions/setup-npmrc@current
with:
Expand All @@ -27,29 +27,16 @@ jobs:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}
- run: npm ci # runs npm prepublish
- name: Bump the version
run: |
echo "VERSION=$(npm version)" >> $GITHUB_ENV
echo "NPM_PACKAGE=$(jq '.name' package.json) >> $GITHUB_ENV
- run: git push --tags
- uses: ./.github/actions/setup-totp
with:
vault-url: ${{ secrets.VAULT_ADDR }}
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}
- name: NPM Publish
run: npm publish --otp=${TOTP_CODE}
- name: Create 'latest' dist-tag
run: npm dist-tag --otp=${TOTP_CODE} add "${NPM_PACKAGE}@${VERSION}" latest
- name: Create 'stack_release' dist-tag
if: ${{ github.event.inputs.is-stack-release }}
run: npm dist-tag --otp=${TOTP_CODE} add "${NPM_PACKAGE}@${VERSION}" stack_release
- name: Create Draft Release Notes
run: >-
gh release create "${VERSION}"
--title="${VERSION}"
--generate-notes
--draft
- run: npx semantic-release --dry-run="${DRY_RUN}"
env:
DRY_RUN: ${{ github.event.inputs.dry-run }}
GITHUB_TOKEN: ${{ github.token }}

- if: always()
uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
with:
Expand Down
20 changes: 20 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/npm",
{
"npmPublish": false,
}
],
[
"@semantic-release/exec",
{
"publishCmd": "npm publish --otp=${process.env.TOTP_CODE}"
}
],
"@semantic-release/github"
]
}
Loading

0 comments on commit 2cacc54

Please sign in to comment.