Merge pull request #211 from somleng/release-please--branches--main--… #560
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".tool-versions" | |
cache: 'npm' | |
- run: npm ci | |
- run: npm run lint --if-present | |
- run: npm test | |
- run: npm run build | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Get release version | |
id: get_release_version | |
run: | | |
commit_message="${{ github.event.head_commit.message }}" | |
[[ "${commit_message,,}" =~ release[[:space:]]*version[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?) ]] && release_version=${BASH_REMATCH[1]} | |
twilio_version=$(npm info twilio version | xargs echo) | |
release_version="${release_version:-${twilio_version}}" | |
echo "release_version=$release_version" >> $GITHUB_OUTPUT | |
- uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
release-type: node | |
release-as: ${{ steps.get_release_version.outputs.release_version }} | |
token: ${{ secrets.SOMLENG_PERSONAL_ACCESS_TOKEN }} | |
- uses: actions/checkout@v4 | |
if: ${{ steps.release.outputs.release_created }} | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
if: ${{ steps.release.outputs.release_created }} | |
with: | |
node-version-file: ".tool-versions" | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish node package | |
if: ${{ steps.release.outputs.release_created }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
npm ci | |
npm run build | |
npm publish |