Skip to content

Commit

Permalink
🔧 chore: Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
honzabubenik committed Oct 13, 2023
1 parent 45ad973 commit bca1669
Show file tree
Hide file tree
Showing 13 changed files with 15,649 additions and 5,969 deletions.
63 changes: 63 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"path": "./node_modules/cz-emoji",
"config": {
"cz-emoji": {
"symbol": true,
"conventional": true,
"format": "{emoji} {type}{scope}: {subject}",
"skipQuestions": [
"issues"
],
"types": [
{
"emoji": "✨",
"code": ":sparkles:",
"description": "A new feature.",
"name": "feature"
},
{
"emoji": "🐛",
"code": ":bug:",
"description": "A bug fix.",
"name": "fix"
},
{
"emoji": "📝",
"code": ":pencil:",
"description": "Documentation changes.",
"name": "docs"
},
{
"emoji": "💄",
"code": ":lipstick:",
"description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).",
"name": "style"
},
{
"emoji": "♻️",
"code": ":recycle:",
"description": "A code change that neither fixes a bug nor adds a feature.",
"name": "refactor"
},
{
"emoji": "⚡️",
"code": ":zap:",
"description": "A code change that improves performance.",
"name": "perf"
},
{
"emoji": "🧪",
"code": ":test_tube:",
"description": "Adding tests or fixing existing tests.",
"name": "test"
},
{
"emoji": "🔧",
"code": ":wrench:",
"description": "Other changes that don't modify src or test files.",
"name": "chore"
}
]
}
}
}
75 changes: 75 additions & 0 deletions .favolosoEmojirc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"emojis": {
"feature": {
"type": "feat",
"emoji": "",
"heading": "✨ Features",
"bump": "minor",
"inChangelog": true,
"index": 20
},
"fix": {
"type": "fix",
"emoji": "🐛",
"heading": "🐛 Fixes",
"bump": "patch",
"inChangelog": true,
"index": 21
},
"docs": {
"type": "docs",
"emoji": "📝",
"heading": "📝 Documentation",
"bump": "patch",
"inChangelog": true,
"index": 22
},
"style": {
"type": "style",
"emoji": "💄",
"heading": "🧰 Other Commits",
"bump": "patch",
"inChangelog": true,
"index": 40
},
"refactor": {
"type": "refactor",
"emoji": "",
"heading": "🧰 Other Commits",
"bump": "patch",
"inChangelog": true,
"index": 41
},
"perf": {
"type": "perf",
"emoji": "",
"heading": "🧰 Other Commits",
"bump": "patch",
"inChangelog": true,
"index": 42
},
"test": {
"type": "test",
"emoji": "🧪",
"heading": "🧰 Other Commits",
"bump": "patch",
"inChangelog": true,
"index": 43
},
"chore": {
"type": "chore",
"emoji": "🔧",
"heading": "🧰 Other Commits",
"bump": "patch",
"inChangelog": true,
"index": 44
},
"release": {
"type": "release",
"emoji": "🚀",
"bump": "patch",
"inChangelog": false,
"index": 90
}
}
}
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release

env:
IS_MERGED_RELEASE_PR: ${{ startsWith(github.event.head_commit.message, '🚀 release:') }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup GIT
uses: fregante/setup-git-user@v2

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
if: ${{ env.IS_MERGED_RELEASE_PR == 'false' }}
run: npm ci --ignore-scripts

- name: Install dependencies and build package
if: ${{ env.IS_MERGED_RELEASE_PR == 'true' }}
run: npm ci

# release-it configuration reference
# https://github.com/release-it/release-it/blob/fdcf005ced6967a86305a3e10fd1d61a3149407b/docs/configuration.md#configuration
# https://github.com/release-it/release-it/blob/HEAD/config/release-it.json

- name: Bump version and update changelog
if: ${{ env.IS_MERGED_RELEASE_PR == 'false' }}
run: npx release-it --no-npm.publish --no-git --no-github.release --ci

- name: Preview changelog
if: ${{ env.IS_MERGED_RELEASE_PR == 'false' }}
id: preview-changelog
run: |
{
echo 'changelog<<EOF'
npx conventional-changelog -p @favoloso/emoji -u
echo EOF
} > "$GITHUB_OUTPUT"
- name: Read package.json version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1

- name: Create release PR
if: ${{ env.IS_MERGED_RELEASE_PR == 'false' }}
uses: peter-evans/create-pull-request@v5
with:
branch: "release"
commit-message: "🚀 release: ${{ steps.package-version.outputs.current-version }}"
delete-branch: true
labels: release-preview
title: ${{ steps.package-version.outputs.current-version }}
body: ${{ steps.preview-changelog.outputs.changelog }}

- name: Read changelog
if: ${{ env.IS_MERGED_RELEASE_PR == 'true' }}
id: read-changelog
run: |
{
echo 'changelog<<EOF'
npx conventional-changelog -p @favoloso/emoji -r 1
echo EOF
} > "$GITHUB_OUTPUT"
- name: Git tag, GitHub release
if: ${{ env.IS_MERGED_RELEASE_PR == 'true' }}
uses: avakar/tag-and-release@v1
with:
tag_name: ${{ steps.package-version.outputs.current-version }}
release_name: ${{ steps.package-version.outputs.current-version }}
body: ${{ steps.read-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Publish NPM package
# if: ${{ env.IS_MERGED_RELEASE_PR == 'true' }}
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
16 changes: 16 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"git": {
"push": false,
"tagName": "${version}",
"commitMessage": "🚀 release: ${version}"
},
"github": {
"releaseName": "${version}"
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "@favoloso/emoji",
"infile": "CHANGELOG.md"
}
}
}
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Changelog
# 2.0.0 (2023-10-13)

All notable changes to this project will be documented in this file.
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.1.0](https://github.com/localazy/ts-api/compare/v1.0.14...v1.1.0) (2023-07-27)
### ✨ Features

### [1.0.14](https://github.com/localazy/ts-api/compare/v1.0.13...v1.0.14) (2023-07-27)
* feature: Api client v2 ([df4bcee](https://github.com/localazy/api-client/commit/df4bcee))


### 🧰 Other Commits

* chore: Add release workflow ([803d60e](https://github.com/localazy/api-client/commit/803d60e))

# Changelog

All notable changes to this project will be documented in this file.
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
<p align="center">
<a href="https://github.com/localazy/api-client"><img src="https://img.shields.io/badge/@localazy-ts--api-066fef?style=for-the-badge" height="22" alt="@localazy/api-client"></a>
<a href="https://npmjs.com/package/@localazy/api-client"><img src="https://img.shields.io/github/package-json/v/localazy/ts-api/main?style=for-the-badge&label=version&color=066fef" height="22" alt="npm"></a>
<a href="#"><img src="https://img.shields.io/badge/schema-OpenAPI-066fef?style=for-the-badge&color=066fef" height="22" alt="schema"></a>
<a href="https://github.com/localazy/api-client/blob/main/LICENSE"><img src="https://img.shields.io/github/license/localazy/ts-api?style=for-the-badge&color=066fef" height="22" alt="license"></a>
<br>
<a href="#"><img src="https://img.shields.io/badge/build-passing-success?style=for-the-badge" height="22" alt="build"></a>
<a href="#"><img src="https://img.shields.io/badge/coverage-100%25-success?style=for-the-badge" height="22" alt="coverage"></a>

[//]: # (<a href="#"><img src="https://img.shields.io/badge/schema-OpenAPI-066fef?style=for-the-badge&color=066fef" height="22" alt="schema"></a>)

[//]: # ( <br>)

[//]: # ( <a href="#"><img src="https://img.shields.io/badge/build-passing-success?style=for-the-badge" height="22" alt="build"></a>)

[//]: # ( <a href="#"><img src="https://img.shields.io/badge/coverage-100%25-success?style=for-the-badge" height="22" alt="coverage"></a>)
</p>

# 📦 Localazy API Client
Expand Down Expand Up @@ -91,7 +95,7 @@ Check out other npm packages from Localazy:
| | NPM package | Description |
|:---------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|----------------------------------------------|
| <img src="https://localazy.com/directus9/assets/3f76ff7b-0e74-4046-bb03-4ca99c3b66d5" width="50" height="50" alt="cli"> | [@localazy/cli](https://www.npmjs.com/package/@localazy/cli) | Localazy CLI tool. |
| <img src="https://localazy.com/directus9/assets/20866781-e69b-4e01-9456-05437487b75c" width="50" height="50" alt="localazy-api"> | [@localazy/ts-api](https://www.npmjs.com/package/@localazy/api-client) | Localazy API client. |
| <img src="https://localazy.com/directus9/assets/20866781-e69b-4e01-9456-05437487b75c" width="50" height="50" alt="localazy-api"> | [@localazy/api-client](https://www.npmjs.com/package/@localazy/api-client) | Localazy API client. |
| <img src="https://localazy.com/directus9/assets/c9e70e4f-8136-432a-8d82-53c3501a9eb4" width="50" height="50" alt="languages"> | [@localazy/languages](https://www.npmjs.com/package/@localazy/languages) | List of all languages supported by Localazy. |
| <img src="https://localazy.com/directus9/assets/1dd05c76-e517-4aea-a3d8-49cfddb40056" width="50" height="50" alt="strapi"> | [@localazy/strapi-plugin](https://www.npmjs.com/package/@localazy/strapi-plugin) | The official Localazy Strapi plugin. |

Expand Down
4 changes: 4 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const config: Config = {
],
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/src/$1',
'lodash-es': 'lodash',
},
moduleFileExtensions: [
'ts',
Expand All @@ -20,6 +21,9 @@ const config: Config = {
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
},
// transformIgnorePatterns: [
// '<rootDir>/node_modules/(?!lodash-es)',
// ],
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
Expand Down
Loading

0 comments on commit bca1669

Please sign in to comment.