Skip to content

Commit 9e82b4a

Browse files
feat!: add renovate and release please, merge and sync (#99)
* feat: add renovate and release please, merge and sync * feat: add nvmrc * fix(deps): use Node 16 * fix: resolve linting errors
1 parent 29e0b42 commit 9e82b4a

11 files changed

+222
-28
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.json]
2+
indent_style = space
3+
indent_size = 4

.github/workflows/ci.yml

-26
This file was deleted.

.github/workflows/lint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [dev, main]
6+
pull_request:
7+
branches: [dev, main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
cache: npm
17+
- name: Install dependencies and lint files
18+
run: |
19+
npm ci
20+
npm run lint

.github/workflows/merge-release.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Merge release
2+
3+
on:
4+
release:
5+
types: [released]
6+
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: Branch to merge into
10+
required: false
11+
type: string
12+
default: main
13+
tag:
14+
description: Tag to merge
15+
required: true
16+
type: string
17+
18+
jobs:
19+
merge-release:
20+
timeout-minutes: 5
21+
permissions:
22+
contents: write
23+
strategy:
24+
fail-fast: true
25+
matrix:
26+
os: [ubuntu-latest]
27+
runs-on: ${{ matrix.os }}
28+
29+
name: Merge tag
30+
31+
steps:
32+
- uses: actions/create-github-app-token@v1
33+
id: app-token
34+
with:
35+
app-id: ${{ vars.GHA_APP_ID }}
36+
private-key: ${{ secrets.GHA_PRIVATE_KEY }}
37+
38+
- name: Determine branch
39+
run: |
40+
echo 'BRANCH='${{ inputs.branch || 'main' }} >> $GITHUB_ENV
41+
42+
- name: Checkout "${{ env.BRANCH }}" branch locally
43+
uses: actions/checkout@v4
44+
with:
45+
ref: ${{ env.BRANCH }}
46+
fetch-tags: true
47+
fetch-depth: 0
48+
token: ${{ steps.app-token.outputs.token }}
49+
50+
- name: Get GitHub App User ID
51+
if: ${{ github.event_name == 'release' }}
52+
id: get-user-id
53+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
54+
env:
55+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
56+
57+
- name: Update values for git user config (release)
58+
if: ${{ github.event_name == 'release' }}
59+
run: |
60+
echo "GIT_USER_NAME=${{ steps.app-token.outputs.app-slug }}[bot]" >> $GITHUB_ENV
61+
echo "GIT_USER_EMAIL=${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" >> $GITHUB_ENV
62+
63+
- name: Update values for git user config (workflow_dispatch)
64+
if: ${{ github.event_name == 'workflow_dispatch' }}
65+
run: |
66+
# fetch user info
67+
user=$(gh api \
68+
-H "Accept: application/vnd.github+json" \
69+
-H "X-GitHub-Api-Version: 2022-11-28" \
70+
/user/$ACCOUNT_ID )
71+
72+
# get user's name and email
73+
# email will be set to null if it is private
74+
name=$(echo $user | jq '.name')
75+
email=$(echo $user | jq '.email')
76+
77+
# store in environment variables to use for setting up git user
78+
echo "GIT_USER_NAME=$name" >> $GITHUB_ENV
79+
echo "GIT_USER_EMAIL=$email" >> $GITHUB_ENV
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
ACCOUNT_ID: ${{ github.actor_id }}
83+
84+
- name: Merge tag to "${{ env.BRANCH }}" branch
85+
run: |
86+
git config --local user.email "$GIT_USER_EMAIL"
87+
git config --local user.name "$GIT_USER_NAME"
88+
git merge ${{ inputs.tag || github.event.release.tag_name }}
89+
git push

.github/workflows/release-please.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish release
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
7+
jobs:
8+
release-please:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 5
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/create-github-app-token@v1
16+
id: app-token
17+
with:
18+
app-id: ${{ vars.GHA_APP_ID }}
19+
private-key: ${{ secrets.GHA_PRIVATE_KEY }}
20+
21+
- uses: googleapis/release-please-action@v4
22+
with:
23+
token: ${{ steps.app-token.outputs.token }}

.github/workflows/sync-branches.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Sync branches
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
sync-branches:
9+
timeout-minutes: 5
10+
permissions:
11+
contents: write
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
runs-on: ${{ matrix.os }}
17+
18+
name: Sync branches
19+
20+
steps:
21+
- uses: actions/create-github-app-token@v1
22+
id: app-token
23+
with:
24+
app-id: ${{ vars.GHA_APP_ID }}
25+
private-key: ${{ secrets.GHA_PRIVATE_KEY }}
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
ref: main
30+
fetch-depth: 0
31+
token: ${{ steps.app-token.outputs.token }}
32+
33+
- name: Get GitHub App user ID
34+
if: ${{ github.event_name == 'push' }}
35+
id: get-user-id
36+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
37+
env:
38+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
39+
40+
- name: Update values for git user config
41+
if: ${{ github.event_name == 'push' }}
42+
run: |
43+
echo "GIT_USER_NAME=${{ steps.app-token.outputs.app-slug }}[bot]" >> $GITHUB_ENV
44+
echo "GIT_USER_EMAIL=${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" >> $GITHUB_ENV
45+
46+
- name: Merge main to dev
47+
run: |
48+
git config --local user.email "$GIT_USER_EMAIL"
49+
git config --local user.name "$GIT_USER_NAME"
50+
git checkout dev
51+
git merge --ff --no-edit main
52+
git push origin dev

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.1.0"
3+
}

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM node:14.14.0-alpine AS builder
1+
FROM node:16-alpine AS builder
22

33
WORKDIR /app
44

5-
RUN apk add --no-cache git
5+
RUN apk add --no-cache git
66

77
COPY package.json ./
88

release-please-config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"changelog-path": "CHANGELOG.md",
3+
"release-type": "node",
4+
"bump-minor-pre-major": false,
5+
"bump-patch-for-minor-pre-major": false,
6+
"draft": false,
7+
"prerelease": false,
8+
"packages": {
9+
".": {
10+
"include-component-in-tag": false
11+
}
12+
},
13+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
14+
}

renovate.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:recommended"],
4+
"lockFileMaintenance": {
5+
"enabled": true,
6+
"automerge": true
7+
},
8+
"packageRules": [
9+
{
10+
"matchUpdateTypes": ["minor", "patch"],
11+
"matchCurrentVersion": "!/^0/",
12+
"automerge": true
13+
}
14+
]
15+
}

0 commit comments

Comments
 (0)