Skip to content

Commit

Permalink
ci: abstract release publishing into a composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
trezy committed Jul 12, 2024
1 parent dc919ba commit 8986f73
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
39 changes: 39 additions & 0 deletions .github/actions/publish-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Publish Release"
description: "Publishes a release to Github and npm"

inputs:
branchName:
description: 'The branch name of from which this release was triggered'
required: false
default: 'latest'
githubToken:
description: 'The Github auth token'
required: false
default: 'latest'
npmToken:
description: 'The npm auth token'
required: false
default: 'latest'

runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Project
uses: ./setup

- name: Build Project
run: npm run build

- name: Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ inputs.githubToken }}

- name: Publish to npm
run: npm publish ./dist/*.tgz --tag ${{ inputs.tag }}
NODE_AUTH_TOKEN: ${{ inputs.npmToken }}
25 changes: 25 additions & 0 deletions .github/workflows/handle-release-branch-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Handle Release Branch Push

on:
push:
branches:
- 'alpha'
- 'beta'
- 'main'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Project
uses: ./.github/actions/publish-release
with:
branchName: ${{ github.head_ref || github.ref_name }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
35 changes: 0 additions & 35 deletions .github/workflows/publish-github-release.yml

This file was deleted.

0 comments on commit 8986f73

Please sign in to comment.