Skip to content

Commit 07f576b

Browse files
committed
Add workflows
1 parent 93c8304 commit 07f576b

File tree

5 files changed

+273
-0
lines changed

5 files changed

+273
-0
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## What's new?
2+
3+
-

.github/release-drafter.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name-template: 'v$RESOLVED_VERSION 🌈'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
4+
categories:
5+
- title: '🌟 Breaking'
6+
label: 'type: breaking'
7+
- title: '🚀 New'
8+
label: 'type: feature'
9+
- title: '🐛 Bug Fixes'
10+
label: 'type: bug'
11+
- title: '🧰 Maintenance'
12+
labels:
13+
- 'type: refactor'
14+
- 'type: test'
15+
- title: '🚨 Security'
16+
label: 'type: security'
17+
- title: '📖 Documentation'
18+
label: 'type: docs'
19+
- title: 'Other changes'
20+
- title: 'Dependency Updates'
21+
label: 'type: dependencies'
22+
23+
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
24+
25+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
26+
27+
version-resolver:
28+
major:
29+
labels:
30+
- 'type: breaking'
31+
minor:
32+
labels:
33+
- 'type: feature'
34+
patch:
35+
labels:
36+
- 'type: bug'
37+
- 'type: test'
38+
- 'type: docs'
39+
- 'type: refactor'
40+
- 'type: dependencies'
41+
- 'type: security'
42+
default: patch
43+
44+
template: |
45+
# What's Changed
46+
47+
$CHANGES
48+
49+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
50+
51+
autolabeler:
52+
- label: 'type: feature'
53+
branch:
54+
- '/^feat(ure)?[/-].+/'
55+
- label: 'type: bug'
56+
branch:
57+
- '/^fix[/-].+/'
58+
- '/^hotfix[/-].+/'
59+
- label: 'type: test'
60+
branch:
61+
- '/^test[/-].+/'
62+
- label: 'type: refactor'
63+
branch:
64+
- '/^refactor[/-].+/'
65+
- label: 'type: docs'
66+
branch:
67+
- '/^doc[/-].+/'
68+
69+
exclude-labels:
70+
- 'skip-changelog'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI(Build and Test)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
# If preinstalled in windows-latest, this step can be skipped
16+
# - name: Setup .NET ${{ matrix.dotnet-version }}
17+
# uses: actions/setup-dotnet@v4
18+
# with:
19+
# dotnet-version: ${{ matrix.dotnet-version }}
20+
21+
- name: Build
22+
run: dotnet build --configuration Release
23+
24+
# no test implemented yet
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Generate release draft and label PRs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
10+
# pull_request event is required only for autolabeler
11+
# pull_request:
12+
# Only following types are handled by the action, but one can default to all as well
13+
# types: [opened, reopened, synchronize]
14+
# pull_request_target event is required for autolabeler to support PRs from forks
15+
pull_request_target:
16+
types: [opened, reopened, synchronize]
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
update_release_draft:
23+
permissions:
24+
# write permission is required to create a github release
25+
contents: write
26+
# write permission is required for autolabeler
27+
# otherwise, read permission is required at least
28+
pull-requests: write
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
# Setup Node.js environment
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: "20.x"
38+
- run: npm install js-yaml
39+
40+
# ラベルが存在しなければ作成
41+
- name: Ensure autolabeler labels exist
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const fs = require('fs');
47+
const yaml = require('js-yaml');
48+
49+
const configPath = '.github/release-drafter.yml';
50+
const content = fs.readFileSync(configPath, 'utf8');
51+
const config = yaml.load(content);
52+
53+
const DEFAULT_COLOR = 'ededed'; // 色は最後で指定
54+
55+
// 既存ラベル一覧を取得
56+
const existingLabelsResponse = await github.rest.issues.listLabelsForRepo({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
per_page: 100,
60+
});
61+
const existingLabels = new Set(existingLabelsResponse.data.map(label => label.name));
62+
63+
// autolabeler + exclude-labels のラベルをセットで保持(重複防止)
64+
const labelsToEnsure = new Set();
65+
66+
// autolabelerのラベル追加
67+
if (Array.isArray(config.autolabeler)) {
68+
for (const rule of config.autolabeler) {
69+
if (rule.label) {
70+
labelsToEnsure.add(rule.label);
71+
}
72+
}
73+
}
74+
75+
// exclude-labelsのラベル追加
76+
if (Array.isArray(config['exclude-labels'])) {
77+
for (const label of config['exclude-labels']) {
78+
labelsToEnsure.add(label);
79+
}
80+
}
81+
82+
// ラベル作成処理
83+
for (const label of labelsToEnsure) {
84+
if (!existingLabels.has(label)) {
85+
console.log(`Creating label: ${label} with color ${DEFAULT_COLOR}`);
86+
await github.rest.issues.createLabel({
87+
owner: context.repo.owner,
88+
repo: context.repo.repo,
89+
name: label,
90+
color: DEFAULT_COLOR,
91+
});
92+
} else {
93+
console.log(`Label already exists: ${label}`);
94+
}
95+
}
96+
97+
# Drafts your next Release notes as Pull Requests are merged into "master"
98+
- uses: release-drafter/release-drafter@v6
99+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
100+
# with:
101+
# config-name: my-config.yml
102+
# disable-autolabeler: true
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
env:
9+
APP_NAME: TouchSenderTablet
10+
APP_PROJECT: TouchSenderTablet.GUI
11+
12+
jobs:
13+
release-packages:
14+
permissions:
15+
contents: write
16+
runs-on: windows-latest
17+
timeout-minutes: 15
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set VERSION variable from tag
23+
shell: bash
24+
run: |
25+
$version = "${{ github.ref_name }}" -replace '^v', ''
26+
echo "VERSION=$version" >> $GITHUB_ENV
27+
28+
- name: Set archive name
29+
shell: bash
30+
run: |
31+
echo "app_x64_framework_name=${{ env.APP_NAME }}_win-x64_framework-dependent_${{ env.VERSION }}" >> $GITHUB_ENV
32+
echo "app_x64_self_name=${{ env.APP_NAME }}_win-x64_${{ env.VERSION }}" >> $GITHUB_ENV
33+
34+
- name: dotnet publish x64 Framework-dependent
35+
run: >
36+
dotnet publish ${{ env.APP_PROJECT}}
37+
-c Release
38+
-r win-x64
39+
-p:Platform=x64
40+
--self-contained false
41+
-p:PublishSingleFile=true
42+
-p:PublishReadyToRun=true
43+
-p:DebugType=none
44+
-p:Version=${{ env.VERSION }}
45+
-o publish\${{ env.app_x64_framework_name }}
46+
47+
- name: dotnet publish x64 Self-contained
48+
run: >
49+
dotnet publish ${{ env.APP_PROJECT}}
50+
-c Release
51+
-r win-x64
52+
-p:Platform=x64
53+
--self-contained true
54+
-p:PublishSingleFile=true
55+
-p:PublishReadyToRun=true
56+
-p:DebugType=none
57+
-p:Version=${{ env.VERSION }}
58+
-o publish\${{ env.app_x64_self_name }}
59+
60+
# Create zip
61+
- name: Create zip archive
62+
shell: pwsh
63+
run: |
64+
Compress-Archive -Path publish\${{ env.app_x64_framework_name }}\* -DestinationPath ${{ env.app_x64_framework_name }}.zip
65+
Compress-Archive -Path publish\${{ env.app_x64_self_name }}\* -DestinationPath ${{ env.app_x64_self_name }}.zip
66+
67+
- name: Upload release artifacts
68+
run: gh release upload "${{ github.ref_name }}" *.zip --clobber
69+
# for using wildcards
70+
shell: bash
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)