Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up semantic release #14

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: Setup
description: Setup Node.js and install dependencies.

inputs:
node_auth_token:
description: The Node.js auth token.
required: true
node_version:
description: The Node.js version.
required: false
default: "20"
registry_url:
description: The Node.js package registry URL.
required: false
default: https://npm.pkg.github.com
install_dependencies:
description: Install dependencies.
required: false
default: "true"

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
if: inputs.install_dependencies == 'true'
with:
cache: npm
node-version: ${{ inputs.node_version }}
registry-url: ${{ inputs.registry_url }}
- name: Setup Node.js without cache
uses: actions/setup-node@v4
if: inputs.install_dependencies == 'false'
with:
node-version: ${{ inputs.node_version }}
registry-url: ${{ inputs.registry_url }}
- name: Install dependencies
if: inputs.install_dependencies == 'true'
shell: bash
run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ inputs.node_auth_token }}
- name: Rebuild Node.js modules
shell: bash
run: npm rebuild
- name: Run postinstall script
shell: bash
run: npm run postinstall --if-present
- name: Run prepare script
shell: bash
run: npm run prepare --if-present
49 changes: 49 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Semantic Release

run-name: Semantic Release from ${{ github.ref_name }}

on:
push:
branches:
- "**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
semantic:
name: Determine version
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
new_release_published: ${{ steps.release.outputs.new_release_published }}
new_release_version: ${{ steps.release.outputs.new_release_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic release
id: release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
release:
name: Release version
runs-on: ubuntu-latest
timeout-minutes: 30
needs: semantic
if: ${{ needs.semantic.outputs.new_release_published == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Release version ${{ steps.release.outputs.new_release_version }} on ${{ github.ref_name }}
run: gh workflow run version.yml --raw-field version=$VERSION --ref $BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VERSION: ${{ needs.semantic.outputs.new_release_version }}
BRANCH: ${{ github.ref_name }}
37 changes: 37 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Version

run-name: Cut ${{ github.event.inputs.version }}

on:
workflow_dispatch:
inputs:
version:
description: Version to cut
required: true

jobs:
tag:
name: Tag
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: ${{ secrets.GIT_USER_NAME }}
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Setup
uses: ./.github/actions/setup
with:
node_auth_token: ${{ secrets.GH_TOKEN }}
- name: Cut ${{ github.event.inputs.version }} version
run: npm version --sign-git-tag=true ${{ github.event.inputs.version }}
11 changes: 11 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true }
],
"plugins": ["@semantic-release/commit-analyzer"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these need to be installed in package.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that they don't as they are not in the package.json on makenew-tsmodule

}
Loading