Merge pull request #53 from whereby/changeset-release/development #9
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: Prerelease | |
on: | |
push: | |
branches: | |
- "development" | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
prerelease: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Run Tests | |
run: yarn test --cache-dir=.turbo | |
- name: Build | |
run: yarn build --cache-dir=.turbo | |
- name: Check for pre.json file existence | |
id: check_files | |
uses: andstor/file-existence-action@v3.0.0 | |
with: | |
files: ".changeset/pre.json" | |
- name: Enter prerelease mode (beta by default) | |
# If .changeset/pre.json does not exist and we did not recently exit | |
# prerelease mode, enter prerelease mode with tag beta | |
if: steps.check_files.outputs.files_exists == 'false' && !contains(github.event.head_commit.message, 'Exit prerelease') | |
run: yarn changeset pre enter beta | |
- name: Create prerelease PR | |
uses: changesets/action@v1 | |
with: | |
version: yarn changeset version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to npm + GitHub | |
id: changesets | |
# Only run publish if we're still in pre mode and the last commit was | |
# via an automatically created Version Packages PR | |
if: steps.check_files.outputs.files_exists == 'true' && contains(github.event.head_commit.message, 'changeset-release/development') | |
uses: changesets/action@v1 | |
with: | |
version: echo "This step should never version" | |
publish: yarn changeset publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Tag release with beta on npm | |
if: steps.changesets.outputs.published == 'true' && contains(fromJSON(steps.changesets.outputs.publishedPackages).*.name, '@whereby.com/browser-sdk') | |
run: npm dist-tag add @whereby.com/browser-sdk@${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }} beta |