Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 17 additions & 1 deletion .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ on:
push:
branches:
- main
workflow_call:
inputs:
GH_APP_ID:
type: string
required: false
secrets:
GH_APP_PEM_FILE:
required: false

concurrency:
group: release-${{ github.ref }}
Expand All @@ -18,9 +26,17 @@ jobs:
issues: write
pull-requests: write
steps:
- name: Create GitHub App token
uses: actions/create-github-app-token@v3
id: gh-app-token
if: ${{ inputs.GH_APP_ID && secrets.GH_APP_PEM_FILE }}
with:
app-id: ${{ inputs.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PEM_FILE }}
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ steps.gh-app-token.outputs.token || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
Expand All @@ -37,5 +53,5 @@ jobs:
run: npm audit signatures
- name: Run Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.gh-app-token.outputs.token || secrets.GITHUB_TOKEN }}
run: npx semantic-release
83 changes: 81 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,88 @@ A collection of GitHub composite actions and reusable workflows

- [Semantic Release Workflow](#semantic-release-workflow)

### Semantic Release Workflow
### Reusable Semantic Release Workflow

[Semantic Release workflow](.github/workflows/semantic-release.yaml) using the Conventional Commits preset to automate versioning, generates [GitHub releases](https://github.com/bruzit/github-actions-and-workflows/releases), and updates the [CHANGELOG](CHANGELOG.md).
Reusable [Semantic Release workflow](.github/workflows/semantic-release.yaml) using the Conventional Commits preset to automate versioning, generates [GitHub releases](https://github.com/bruzit/github-actions-and-workflows/releases), and updates the [CHANGELOG](CHANGELOG.md).

## Usage

### Use Semantic Release Workflow

Create a workflow, for example, `.github/workflows/semantic-release.yaml`:

```yaml
---
name: Semantic Release

on:
push:
branches:
- main

jobs:
release:
name: Release
uses: bruzit/github-actions-and-workflows/.github/workflows/semantic-release.yaml@v0.2.0
with:
GH_APP_ID: ${{ vars.GH_APP_SEM_REL_ID }}
secrets:
GH_APP_PEM_FILE: ${{ secrets.GH_APP_SEM_REL_PEM_FILE }}
```

To create a GitHub App and a GitHub App Installation:

- GitHub
- _Organization_ / Settings / Developer settings / GitHub Apps
- **New GitHub App**
- Create GitHub App
- GitHub App name: _name_
- Description: _description_
- Homepage URL: _homepage URL_
- Webhook
- Active: off
- Permissions
- Organization permissions
- Contents: Read and write
- Issues: Read and write
- Pull requests: Read and write
- Where can this GitHub App be installed?: _choose what suits you best_
- **Create GitHub App**
- _your app_
- General
- **Generate a private key**
- Install App
- _your organization_: **Install**
- _Repository_ / Settings / Secrets and variables / Actions
- Secrets
- Repository secrets / **New repository secret**
- Name: `GH_APP_PEM_FILE`
- Secret: _content of the PEM file_
- **Add secret**
- Variables
- Repository variables / **New repository variable**
- Name: `GH_APP_ID`
- Value: _GitHub App ID_
- **Add variable**

Configure Semantic Release in the repository, for example, `.releaserc.yaml`:

```yaml
---
branches:
- main
plugins:
- - "@semantic-release/commit-analyzer"
- preset: conventionalcommits
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
- "@semantic-release/github"
- - "@semantic-release/changelog"
- changelogTitle: '# Changelog'
- - "@semantic-release/git"
- assets:
- CHANGELOG.md
```

## Copyright and Licensing

Expand Down