-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): adds github actions workflow
- Loading branch information
1 parent
9b2e8d8
commit eaf4db1
Showing
12 changed files
with
286 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Dependencies Workflow | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
install-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: Install dependencies with pnpm | ||
run: pnpm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Linter Workflow | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
GITHUB_TOKEN: | ||
description: 'GitHub Token with necessary permissions' | ||
required: true | ||
|
||
jobs: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: 'code-quality-${{ github.ref }}' | ||
cancel-in-progress: false | ||
|
||
steps: | ||
- name: Calls Install Dependencies | ||
uses: ./.github/lib/dependencies.workflow.yml | ||
|
||
- name: Run Commitlint | ||
run: | | ||
git log -1 --pretty=%B | pnpm exec commitlint | ||
- name: Run ESLint | ||
run: pnpm eslint . --max-warnings=0 | ||
|
||
- name: Run Prettier | ||
run: pnpm prettier --check . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release-branch-prefix: | ||
description: 'Prefix for release branches' | ||
required: false | ||
type: string | ||
default: 'release-' | ||
release-label: | ||
description: 'Label to add to the release pull request' | ||
required: false | ||
type: string | ||
default: 'release' | ||
secrets: | ||
GH_TOKEN: | ||
description: 'GitHub Personal Access Token with repo permissions' | ||
required: true | ||
PAT_FORCE_PUSH: | ||
description: 'Personal Access Token with permissions to push to protected branches' | ||
required: true | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Assets | ||
run: ${{ inputs.build-command }} | ||
|
||
- name: Run Semantic Release | ||
id: semantic_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: npx semantic-release | ||
|
||
- name: Create Release Branch | ||
if: success() && steps.semantic_release.outputs.nextRelease | ||
run: | | ||
VERSION=${{ steps.semantic_release.outputs.nextRelease.version }} | ||
git checkout -b ${{ inputs.release-branch-prefix }}${VERSION} | ||
- name: Push Release Branch | ||
if: success() && steps.semantic_release.outputs.nextRelease | ||
env: | ||
PAT: ${{ secrets.PAT_FORCE_PUSH }} | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git remote set-url origin https://x-access-token:${PAT}@github.com/${{ github.repository }}.git | ||
git push origin ${{ inputs.release-branch-prefix }}${VERSION} --force | ||
- name: Extract Version from package.json | ||
id: extract_version | ||
run: | | ||
VERSION=$(jq -r .version package.json) | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Extract Changelog | ||
id: changelog | ||
run: | | ||
CHANGELOG=$(awk '/^## \[/ {print; exit}' CHANGELOG.md) | ||
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT | ||
- name: Create Pull Request to Main | ||
if: success() && steps.semantic_release.outputs.nextRelease | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: 'chore/release: ${{ steps.extract_version.outputs.version }}' | ||
body: | | ||
This is an automated pull request for release version `${{ steps.extract_version.outputs.version }}`. | ||
**Changelog:** | ||
``` | ||
${{ steps.changelog.outputs.changelog }} | ||
``` | ||
head: ${{ inputs.release-branch-prefix }}${{ steps.extract_version.outputs.version }} | ||
base: main | ||
commit-message: 'chore/release: ${{ steps.extract_version.outputs.version }} [skip ci]' | ||
labels: ${{ inputs.release-label }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Code Quality | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: 'pages' | ||
cancel-in-progress: false | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Dependencies | ||
uses: ./.github/lib/dependencies.workflow.yml | ||
|
||
- name: Code Quality | ||
uses: ./.github/lib/linter.workflow.yml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Call Release Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
- name: Install Dependencies | ||
uses: ./.github/lib/dependencies.workflow.yml | ||
|
||
- name: Release | ||
uses: ./.github/lib/release.workflow.yml | ||
with: | ||
release-branch-prefix: 'release-' | ||
release-label: 'release' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PAT_FORCE_PUSH: ${{ secrets.GH_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Automated Release Workflow with `semantic-release` | ||
|
||
This repository utilizes a **reusable GitHub Actions workflow** to automate the release process | ||
using `semantic-release`. This setup ensures consistent and efficient releases across multiple | ||
projects. | ||
|
||
## Features | ||
|
||
- **Automated Versioning:** Automatically determines the next version based on commit messages. | ||
- **Changelog Generation:** Generates and updates the `CHANGELOG.md` with release notes. | ||
- **Release Branching:** Creates dedicated release branches for each version. | ||
- **Pull Request Automation:** Automatically creates a PR from the release branch to `main` for | ||
review and merging. | ||
- **Asset Attachment:** Attaches build artifacts to GitHub Releases. | ||
|
||
## Setup Guide | ||
|
||
Follow these steps to integrate the reusable release workflow into your project. | ||
|
||
### 1. **Add Required Secrets** | ||
|
||
Ensure that your repository has the necessary secrets configured: | ||
|
||
1. **Navigate to Repository Settings:** | ||
|
||
- Go to your repository on GitHub. | ||
- Click on **Settings**. | ||
|
||
2. **Add Secrets:** | ||
- Go to **Secrets and variables** > **Actions** > **New repository secret**. | ||
- Add the following secrets: | ||
- `GH_TOKEN`: Your GitHub Personal Access Token with `repo` permissions. | ||
- `PAT_FORCE_PUSH`: Your Personal Access Token with permissions to push to protected branches. | ||
|
||
### 2. **Create the Reusable Workflow** | ||
|
||
The reusable workflow is already defined in this repository at | ||
`.github/workflows/reusable-release.yml`. If you're using this repository as the source, you can | ||
skip this step. Otherwise, ensure that your reusable workflow is correctly defined and accessible. | ||
|
||
### 3. **Create an Invoking Workflow** | ||
|
||
Add a new workflow file in your repository to call the reusable release workflow. | ||
|
||
**File Path:** `.github/workflows/call-reusable-release.yml` | ||
|
||
**Content:** | ||
|
||
```yaml | ||
name: Call Reusable Release Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
uses: @kurocado-studio/style-guide/.github/workflows/reusable-release.yml | ||
with: | ||
node-version: '18' | ||
build-command: 'npm run build' | ||
release-branch-prefix: 'release-' | ||
release-label: 'release' | ||
secrets: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
PAT_FORCE_PUSH: ${{ secrets.PAT_FORCE_PUSH }}# Workflows | ||
``` |
Oops, something went wrong.