Skip to content

Commit

Permalink
Merge pull request #2 from tshion/develop
Browse files Browse the repository at this point in the history
Publish 2025.01.02
  • Loading branch information
tshion authored Jan 2, 2025
2 parents 502345d + e2db52b commit 500dae6
Show file tree
Hide file tree
Showing 25 changed files with 4,054 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts/"
}
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
day: 'tuesday'
assignees:
- 'tshion'

- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
day: 'tuesday'
assignees:
- 'tshion'
13 changes: 13 additions & 0 deletions .github/scripts/can-release.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# 引数で指定されたGit タグ名でリリースできるかどうか
#
# $1 -> Git タグ名
#
# 注意事項
# * GitHub CLI のアクセス権限設定が必要

if gh release view $1 --repo tshion/gapi-utils-nodejs > /dev/null; then
echo "$1 is already released!"
exit 1
fi
25 changes: 25 additions & 0 deletions .github/scripts/presume-release-notes.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# まだリリースしていないGit タグのリリースノートの推定
# ※GitHub CLI のアクセス権限等の設定が必要
#
# $1 -> リリースしようとしているGit タグ名
# $2 -> $1 があるGit ブランチ名

repoName="tshion/gapi-utils-nodejs"

latestTag=$(gh release list \
--exclude-drafts \
--exclude-pre-releases \
--order desc --limit 1 \
--json tagName --jq '.[].tagName' \
)

gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$repoName/releases/generate-notes" \
-f "tag_name=preview$1" \
-f "target_commitish=$2" \
-f "previous_tag_name=$latestTag"
87 changes: 87 additions & 0 deletions .github/workflows/create-version-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Create a pull request for set version

on:
workflow_dispatch:

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

jobs:
create:
if: ${{ github.ref_type == 'branch' && github.ref_name == 'develop' }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4

- name: Decide version
id: meta
run: |
version=$(date +%Y.%m.%d)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Can release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.meta.outputs.version }}
run: bash .github/scripts/can-release.bash "$TAG"

# https://github.com/actions/setup-node
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: ./package-lock.json

- name: Set version
env:
VERSION: ${{ steps.meta.outputs.version }}
run: npm version "$VERSION" --allow-same-version --no-git-tag-version

- run: npm ci

- run: npm run compile

- name: Generate diff notes
id: notes
env:
GH_TOKEN: ${{ github.token }}
REF_NAME: ${{ github.ref_name }}
TAG: ${{ steps.meta.outputs.version }}
run: |
response=$(bash .github/scripts/presume-release-notes.bash "$TAG" "$REF_NAME")
echo "response=$response" >> "$GITHUB_OUTPUT"
echo "$response"
# https://github.com/tshion/apply-git-user
- uses: tshion/[email protected]
with:
user: github-actions

- name: git add & push
env:
VERSION: ${{ steps.meta.outputs.version }}
run: |
branch="feature/$VERSION"
message="Update $VERSION"
git switch --create "$branch"
git add build
git add package.json
git add package-lock.json
git commit --message "$message"
git push --set-upstream origin "$branch"
- name: Create pull request
env:
ASSIGNEE: tshion
BASE: ${{ github.ref_name }}
BODY: ${{ fromJson(steps.notes.outputs.response).body }}
GH_TOKEN: ${{ github.token }}
TITLE: '${{ steps.meta.outputs.version }}'
run: gh pr create --assignee "$ASSIGNEE" --base "$BASE" --title "$TITLE" --body "$BODY"
45 changes: 45 additions & 0 deletions .github/workflows/prepare-release-note.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Prepare a GitHub release note

on:
push:
branches:
- released

workflow_dispatch:

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

jobs:
preparation:
if: ${{ github.ref_type == 'branch' }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4

# https://github.com/actions/setup-node
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: ./package-lock.json

- name: Get version name
id: meta
run: |
version=$(node -p "require('./package.json').version")
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create draft release notes
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
git tag "$VERSION"
git push origin "$VERSION"
gh release create "$VERSION" --draft --generate-notes --title "$VERSION"
Loading

0 comments on commit 500dae6

Please sign in to comment.