Skip to content

Commit

Permalink
Merge pull request #34 from tshion/develop
Browse files Browse the repository at this point in the history
Merge 2.0.1
  • Loading branch information
tshion authored Jun 29, 2024
2 parents fd1d443 + fe7610f commit 4e3279d
Show file tree
Hide file tree
Showing 13 changed files with 536 additions and 204 deletions.
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/apply-git-user > /dev/null; then
echo "$1 is already released!"
exit 1
fi
8 changes: 8 additions & 0 deletions .github/scripts/create-test-config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

require 'json'

config = { os: ["ubuntu-latest", "windows-latest", "macos-latest"] }
File.open("config.json", "w") { |file|
file.write(config.to_json)
}
File renamed without changes.
82 changes: 82 additions & 0 deletions .github/workflows/140-create-version-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: 140 Create version pull request

on:
workflow_dispatch:
inputs:
versionMajor:
description: "バージョン情報: major"
required: true
type: string
versionMinor:
description: "バージョン情報: minor"
required: true
type: string
versionPatch:
description: "バージョン情報: patch"
required: true
type: string

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

jobs:
create-pr:
if: ${{ github.ref_type == 'branch' }}
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
pull-requests: 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: Decide version
id: meta
env:
GH_TOKEN: ${{ github.token }}
VERSION: "${{ inputs.versionMajor }}.${{ inputs.versionMinor }}.${{ inputs.versionPatch }}"
run: |
npm version "$VERSION" --no-git-tag-version
version=$(node -p "require('./package.json').version")
bash ./.github/scripts/can-release.bash "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- run: npm ci

- run: npm test

- run: npm run build

# https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Set up git user
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Create a pull request
env:
ASSIGNEE: tshion
BASE: ${{ github.ref_name }}
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
branch="feature/$VERSION"
message="Update $VERSION"
git switch --create "$branch"
git add --all compiled/*
git add package-lock.json
git add package.json
git commit --message "$message"
git push --set-upstream origin "$branch"
gh pr create --assignee "$ASSIGNEE" --base "$BASE" --title "$message" --body ""
47 changes: 47 additions & 0 deletions .github/workflows/160-create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 160 Create release pull request

on:
workflow_dispatch:

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

jobs:
test-action:
if: ${{ github.ref_name == 'develop' }}
uses: ./.github/workflows/160a-test-action.yml


create-pr:
needs: test-action
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: 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 pull request
env:
ASSIGNEE: tshion
BODY: "result: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
GH_TOKEN: ${{ github.token }}
TITLE: "Merge ${{ steps.meta.outputs.version }}"
run: |
gh pr create --assignee "$ASSIGNEE" --base released --title "$TITLE" --body "$BODY"
158 changes: 158 additions & 0 deletions .github/workflows/160a-test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: 160a Test action

on:
workflow_call:

workflow_dispatch:

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

jobs:
config:
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
configs: ${{ steps.result.outputs.configs }}
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4

- id: result
run: |
ruby ./.github/scripts/create-test-config.rb
echo "configs=$(cat config.json)" >> "$GITHUB_OUTPUT"
actions-user:
needs: config
strategy:
matrix: ${{ fromJson(needs.config.outputs.configs) }}
max-parallel: 1
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: tools

# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: main

- uses: ./tools/
with:
path: ./main/
user: actions-user
- working-directory: ./main/
run: bash ../tools/.github/scripts/display.bash

- uses: ./tools/
with:
global: TRUE
user: ACTIONS-USER
- run: bash ./tools/.github/scripts/display.bash


github-actions:
needs: config
strategy:
matrix: ${{ fromJson(needs.config.outputs.configs) }}
max-parallel: 1
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: tools

# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: main

- uses: ./tools/
with:
path: ./main/
user: github-actions
- working-directory: ./main/
run: bash ../tools/.github/scripts/display.bash

- uses: ./tools/
with:
global: TRUE
user: GITHUB-ACTIONS
- run: bash ./tools/.github/scripts/display.bash


latest-commit:
needs: config
strategy:
matrix: ${{ fromJson(needs.config.outputs.configs) }}
max-parallel: 1
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: tools

# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: main

- uses: ./tools/
with:
path: ./main/
user: latest-commit
- working-directory: ./main/
run: bash ../tools/.github/scripts/display.bash

- uses: ./tools/
with:
path: ./tools/
global: TRUE
user: LATEST-COMMIT
- run: bash ./tools/.github/scripts/display.bash


specific:
needs: config
strategy:
matrix: ${{ fromJson(needs.config.outputs.configs) }}
max-parallel: 1
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: tools

# https://github.com/actions/checkout
- uses: actions/checkout@v4
with:
path: main

- uses: ./tools/
with:
path: ./main/
user: specific
email: [email protected]
name: hoge
- working-directory: ./main/
run: bash ../tools/.github/scripts/display.bash

- uses: ./tools/
with:
global: TRUE
user: SPECIFIC
email: [email protected]
name: hoge
- run: bash ./tools/.github/scripts/display.bash
45 changes: 45 additions & 0 deletions .github/workflows/180-release-preparation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 180 Release preparation

on:
push:
branches:
- released

workflow_dispatch:

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

jobs:
preparation:
if: ${{ github.ref_type == 'branch' }}
runs-on: ubuntu-latest
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 4e3279d

Please sign in to comment.