Skip to content

Commit

Permalink
refactor(workflows): separate release and publish into two different …
Browse files Browse the repository at this point in the history
…shared workflows (#11)

this actually brings back the ones i had before, and references both of them from the release-and-publish workflow.

easier sharing and better readability, yay!
  • Loading branch information
aimeerivers authored Nov 29, 2023
1 parent c5d7972 commit ef7cadd
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 46 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/publish-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Please

on:
workflow_call:
inputs:
github_ref:
description: The git ref to publish
type: string
required: true
secrets:
READONLY_NPM_TOKEN:
description: Needed to install private @hedia npm packages
required: true
PUBLISHING_NPM_TOKEN:
description: Needed to publish @hedia npm packages
required: true

jobs:
publish-please:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.github_ref }}
fetch-depth: 1

- name: Setup Node.js Environment
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
always-auth: true
registry-url: https://registry.npmjs.org
scope: "@hedia"

- name: Install Dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }}

- name: Build
run: npm run build --if-present

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.PUBLISHING_NPM_TOKEN }}
52 changes: 6 additions & 46 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ name: Release and Publish

on:
workflow_call:
secrets:
READONLY_NPM_TOKEN:
description: Needed to install private @hedia npm packages
required: true
PUBLISHING_NPM_TOKEN:
description: Needed to publish @hedia npm packages
required: true

permissions:
contents: write
Expand All @@ -17,46 +10,13 @@ permissions:
jobs:
release-and-publish:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'autorelease: pending')
)
steps:
- uses: google-github-actions/release-please-action@v3
- name: Release Please
uses: hedia-team/.github/.github/workflows/release-please.yml@latest
id: release
with:
release-type: node

- if: steps.release.outputs.release_created == 'true'
name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 1

- if: steps.release.outputs.release_created == 'true'
name: Setup Node.js Environment
uses: actions/setup-node@v3
- name: Publish Please
if: steps.release.outputs.release_created == 'true'
uses: hedia-team/.github/.github/workflows/publish-please.yml@latest
with:
node-version-file: "package.json"
always-auth: true
registry-url: https://registry.npmjs.org
scope: "@hedia"

- if: steps.release.outputs.release_created == 'true'
name: Install Dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }}

- if: steps.release.outputs.release_created == 'true'
name: Build
run: npm run build --if-present

- if: steps.release.outputs.release_created == 'true'
name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.PUBLISHING_NPM_TOKEN }}
github_ref: ${{ github.ref }}
22 changes: 22 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Please

on:
workflow_call:

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'autorelease: pending')
)
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node

0 comments on commit ef7cadd

Please sign in to comment.