Skip to content

Commit

Permalink
feat: automate release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Embraser01 committed Apr 17, 2024
1 parent 8dcb61f commit a040c2c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 11 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js 18
uses: actions/setup-node@v3
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Yarn install
run: yarn
Expand All @@ -32,15 +32,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js 18
uses: actions/setup-node@v3
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Yarn install
run: yarn

- name: TypeScript
run: yarn test:types

versions:
name: Checking version changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Yarn version check
run: yarn version check
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release Package
on:
workflow_dispatch:
inputs:
prerelease:
description: 'Is this a prerelease?'
required: false
default: false
type: boolean

permissions:
contents: write

jobs:
release:
name: Release changed packages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Yarn install
run: yarn

- name: Apply version to packages
id: version-apply
run: yarn version apply -all ${{ inputs.prerelease && '--prerelease' }}

- name: Compute commit message
uses: actions/github-script@v7
id: commit-message
with:
result-encoding: string
script: |
return `chore: release ${versions.map((v) => `${v.ident}@${v.newVersion}`)}`;
# Commiting using the GitHub action bot
# More info here: https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Create commit of changed files
run: |
git add .
git commit -m "${{ steps.commit-message.outputs.result }}" --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
git push
- name: Publish changed packages
run: yarn workspaces foreach -pt --since ${{ github.ref }} npm publish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
3 changes: 3 additions & 0 deletions .yarn/versions/8fdf1dee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
"@typoas/cli": patch
"@typoas/generator": patch

0 comments on commit a040c2c

Please sign in to comment.