Skip to content

Commit

Permalink
build: release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed May 6, 2024
1 parent 7f71485 commit 87f6de0
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 31 deletions.
30 changes: 30 additions & 0 deletions .github/actions/npm-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish Package to npmjs

runs:
using: "composite"
steps:
- uses: actions/checkout@v4

- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
node_modules
*/*/node_modules
key: yarn-deps-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Transpile to JavaScript
run: yarn transpile

- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35 changes: 5 additions & 30 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
name: Publish Package to npmjs
name: publish npm

on:
release:
types: [created]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v4

- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
node_modules
*/*/node_modules
key: yarn-deps-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: |
yarn
- name: Transpile to JavaScript
run: yarn transpile

- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish package
uses: ./.github/action/npm-publish
secrets: inherit
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release

on:
workflow_dispatch:
inputs:
version:
description: 'SemVer that will be used for publishing (e.g. "0.0.1")'
required: true
type: string

jobs:
Prepare-Release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Prepare ${{ inputs.version }} release
run: |
git config user.name "think-it-account"
git config user.email "[email protected]"
sed -i 's/"version":.*/"version": "${{ inputs.version }}",/g' package.json
git add .
git commit -m "Prepare release ${{ inputs.version }}"
git push origin main
git tag --force v${{ inputs.version }}
git push --force origin v${{ inputs.version }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
tag: ${{ inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
makeLatest: true
removeArtifacts: true

- name: Publish package
uses: ./.github/action/npm-publish
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull request testing
name: test

on:
push:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ connectors with capabilities described in the
Please, adhere to the [CONTRIBUTING](CONTRIBUTING.md) guidelines when suggesting
changes in this repository.

### Release
The `release` github action workflow takes care of release.

## License

Copyright 2022-2023 Think.iT GmbH.
Expand Down

0 comments on commit 87f6de0

Please sign in to comment.