From 7cf0a257d84eed488c75ccb25de151beb434246f Mon Sep 17 00:00:00 2001 From: cssho Date: Fri, 6 Nov 2026 08:42:12 +0900 Subject: [PATCH 1/4] =?UTF-8?q?NuGet=20=E3=83=91=E3=83=83=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=A8=E3=80=81?= =?UTF-8?q?GitHub=20Actions=20=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=BB=E5=85=AC=E9=96=8B=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - パッケージ情報(作成者・著作権を cssho にそろえる、MIT、README・シンボル・Source Link)を設定 - パッケージ作成時に net8.0 版から netstandard2.0 版の公開 API が欠けていないかを検証する - push・PR で Ubuntu と Windows × コアの両方のビルドをテストし、パッケージを作る - v* タグの push で、release Environment(承認後)から Trusted Publishing で nuget.org に公開する - Linux で SkiaSharp のテストを動かすため、テストプロジェクトにネイティブライブラリを追加 - README にインストール方法、CLAUDE.md にリリース手順を追記 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE --- .github/workflows/build.yml | 81 +++++++++++++++++++ CLAUDE.md | 8 ++ Directory.Build.props | 30 ++++++- README.md | 9 +++ .../ZipConvertCustomerBarCode.Tests.csproj | 2 + 5 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d93fde2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,81 @@ +# テスト・パッケージ作成と、タグ(v2.0.0 など)を push したときの nuget.org への公開 +# 公開は nuget.org の Trusted Publishing(このファイル名 build.yml を登録する)を使う +name: build + +on: + push: + branches: [master] + tags: ['v*'] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + # コアは netstandard2.0 と net8.0 で処理が異なる(#if NET8_0_OR_GREATER)ため、両方のビルドをテストする + name: test (${{ matrix.os }}, ${{ matrix.core }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + core: [net8.0, netstandard2.0] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + - name: テスト + run: dotnet test -p:CoreTargetFramework=${{ matrix.core }} + + pack: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + - name: バージョン + id: version + shell: bash + run: | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + else + # タグ以外はプレリリース版(公開はしない) + echo "version=0.0.0-ci.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT" + fi + - name: パッケージ作成 + run: dotnet pack ZipConvertCustomerBarCode.sln -c Release -o artifacts -p:Version=${{ steps.version.outputs.version }} + - uses: actions/upload-artifact@v4 + with: + name: packages + path: artifacts/ + + publish: + if: startsWith(github.ref, 'refs/tags/v') + needs: pack + runs-on: ubuntu-latest + # release Environment: v* タグのみ・承認後に実行。nuget.org の Trusted Publishing のポリシーもこの Environment に限定している + environment: release + permissions: + id-token: write # Trusted Publishing の短期間の API キーを取得するため + steps: + - uses: actions/download-artifact@v4 + with: + name: packages + path: artifacts + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + - name: NuGet ログイン(Trusted Publishing) + id: login + uses: NuGet/login@v1 + with: + user: ${{ secrets.NUGET_USER }} # release Environment の Secret。nuget.org のユーザー名(プロフィール名。メールアドレスではない) + - name: nuget.org に公開 + # .snupkg(シンボルパッケージ)は同じフォルダーにあれば一緒に公開される + run: dotnet nuget push "artifacts/*.nupkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/CLAUDE.md b/CLAUDE.md index c5b67b9..0834aa5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,6 +27,14 @@ - System.Drawing のテストは Windows 以外ではスキップされる。 - `TestData/ken_all_sample.csv` は utf_ken_all.csv の形式で手書きしたテスト用データ(実データの抜粋ではない)。実際の郵便番号データ(約12万件)はリポジトリに含めない。 - `TestData/jigyosyo_sample.csv` は JIGYOSYO.CSV の形式で手書きしたテスト用データで、実データと同じく Shift_JIS・CRLF。編集するときは UTF-8 で書いて `iconv -f UTF-8 -t CP932` で変換する(`.gitattributes` で binary 指定)。 +- テストプロジェクトの `SkiaSharp.NativeAssets.Linux.NoDependencies` は CI(Linux)用。ライブラリ本体には追加しない。 + +## CI・リリース + +- `.github/workflows/build.yml`: push・PR で Ubuntu と Windows × コアの両方のビルドをテストし、パッケージを作る。 +- リリースは `v2.0.0` のようなタグを push すると、タグのバージョンで3パッケージを nuget.org に公開する(Trusted Publishing。ワークフローのファイル名 `build.yml` と Environment 名 `release` を nuget.org に登録しているので、どちらも名前を変えない)。 +- 公開ジョブは GitHub の `release` Environment で動く(`v*` タグのみ、cssho の承認後に実行。Secret `NUGET_USER` もこの Environment にある)。`Directory.Build.props` の `Version` はローカル用で、公開時はタグが優先される。 +- パッケージ作成時の検証(`EnablePackageValidation`)で、net8.0 版から netstandard2.0 版の公開 API が欠けているとエラー(CP0002)になる。 ## コード規約 diff --git a/Directory.Build.props b/Directory.Build.props index fc534f5..7132875 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,36 @@ + 2.0.0 - Toshiba + cssho ZipConvertCustomerBarCode - Copyright © Toshiba 2015 + Copyright (c) 2015 cssho + + + MIT + https://github.com/cssho/ZipConvertCustomerBarCode + https://github.com/cssho/ZipConvertCustomerBarCode + git + customer-barcode;barcode;japan-post;postal-code;zipcode;カスタマバーコード;郵便番号 + README.md + true + snupkg + + true + + + + true + + + + + + diff --git a/README.md b/README.md index b476ccf..8296299 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,15 @@ SkiaSharp を Linux で使う場合は、利用側で `SkiaSharp.NativeAssets.Linux` パッケージも参照してください。 +## インストール +NuGet から追加します。描画パッケージを追加すると、コアも一緒に追加されます。 + +``` +dotnet add package ZipConvertCustomerBarCode +dotnet add package ZipConvertCustomerBarCode.SkiaSharp # SkiaSharp で描画する場合 +dotnet add package ZipConvertCustomerBarCode.Drawing # System.Drawing で描画する場合 +``` + ## 使い方 ### バーコード生成 ```csharp diff --git a/ZipConvertCustomerBarCode.Tests/ZipConvertCustomerBarCode.Tests.csproj b/ZipConvertCustomerBarCode.Tests/ZipConvertCustomerBarCode.Tests.csproj index bc1b47e..9efae28 100644 --- a/ZipConvertCustomerBarCode.Tests/ZipConvertCustomerBarCode.Tests.csproj +++ b/ZipConvertCustomerBarCode.Tests/ZipConvertCustomerBarCode.Tests.csproj @@ -10,6 +10,8 @@ + + From 3a2a1ca8720731b2f024cb06b3bcafe5a52e8d35 Mon Sep 17 00:00:00 2001 From: cssho Date: Fri, 6 Nov 2026 08:45:33 +0900 Subject: [PATCH 2/4] =?UTF-8?q?GitHub=20Actions=20=E3=81=AE=E5=90=84?= =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=20Node.j?= =?UTF-8?q?s=2024=20=E5=AF=BE=E5=BF=9C=E3=81=AE=E6=9C=80=E6=96=B0=E7=89=88?= =?UTF-8?q?=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit actions/checkout@v4・actions/setup-dotnet@v4 が廃止予定の Node.js 20 で動いている警告が出ていたため、 checkout@v7、setup-dotnet@v6、upload-artifact@v7、download-artifact@v8 に更新した。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d93fde2..4d345df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,8 @@ jobs: os: [ubuntu-latest, windows-latest] core: [net8.0, netstandard2.0] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v4 + - uses: actions/checkout@v7 + - uses: actions/setup-dotnet@v6 with: dotnet-version: 10.0.x - name: テスト @@ -34,8 +34,8 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v4 + - uses: actions/checkout@v7 + - uses: actions/setup-dotnet@v6 with: dotnet-version: 10.0.x - name: バージョン @@ -50,7 +50,7 @@ jobs: fi - name: パッケージ作成 run: dotnet pack ZipConvertCustomerBarCode.sln -c Release -o artifacts -p:Version=${{ steps.version.outputs.version }} - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: packages path: artifacts/ @@ -64,11 +64,11 @@ jobs: permissions: id-token: write # Trusted Publishing の短期間の API キーを取得するため steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v8 with: name: packages path: artifacts - - uses: actions/setup-dotnet@v4 + - uses: actions/setup-dotnet@v6 with: dotnet-version: 10.0.x - name: NuGet ログイン(Trusted Publishing) From b423490f5b37b73f537b9325e6d2ea08e1300144 Mon Sep 17 00:00:00 2001 From: cssho Date: Fri, 6 Nov 2026 08:58:01 +0900 Subject: [PATCH 3/4] =?UTF-8?q?GitHub=20Actions=20=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=20actions.lock=20?= =?UTF-8?q?=E3=81=A7=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88=E3=81=AB=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E3=81=97=E3=80=81Dependabot=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gh actions-lock で .github/workflows/actions.lock を作成し、ワークフローのアクションを正確なタグとコミットに固定した - ロックファイルを PR・push・週1回で検証する verify-lockfile.yml を追加 - アクションの更新を Dependabot で行い、リリースから7日待つ(cooldown)ようにした - CLAUDE.md にロックファイルの手順を追記 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE --- .github/dependabot.yml | 11 ++++++++ .github/workflows/actions.lock | 39 +++++++++++++++++++++++++++ .github/workflows/build.yml | 16 +++++------ .github/workflows/verify-lockfile.yml | 29 ++++++++++++++++++++ CLAUDE.md | 1 + 5 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/actions.lock create mode 100644 .github/workflows/verify-lockfile.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..38bafdf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# GitHub Actions のアクションの更新 +# ワークフローは actions.lock でロックしているが、Dependabot は更新の PR でロックファイルも作り直す +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + # 出たばかりのリリースは、問題(乗っ取りなど)が見つかる前に取り込まないよう7日待つ(既定は3日) + cooldown: + default-days: 7 diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 0000000..5ec14d2 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,39 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/build.yml': + - 'actions/checkout@v7.0.1' + - 'actions/download-artifact@v8.0.2' + - 'actions/setup-dotnet@v6.1.0' + - 'actions/upload-artifact@v7.0.2' + - 'nuget/login@v1.2.0' + '.github/workflows/verify-lockfile.yml': + - 'actions/checkout@v7.0.1' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/download-artifact@v8.0.2': + ref: 'v8.0.2' + commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333' + owner_id: 44036562 + repo_id: 192626254 + 'actions/setup-dotnet@v6.1.0': + ref: 'v6.1.0' + commit: 'sha1-0f4a354dd5547a28c70b7853dbd95d5b67886e73' + owner_id: 44036562 + repo_id: 192625306 + 'actions/upload-artifact@v7.0.2': + ref: 'v7.0.2' + commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9' + owner_id: 44036562 + repo_id: 192625955 + 'nuget/login@v1.2.0': + ref: 'v1.2.0' + commit: 'sha1-8d196754b4036150537f80ac539e15c2f1028841' + owner_id: 968310 + repo_id: 1037624552 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d345df..e78267b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,8 @@ jobs: os: [ubuntu-latest, windows-latest] core: [net8.0, netstandard2.0] steps: - - uses: actions/checkout@v7 - - uses: actions/setup-dotnet@v6 + - uses: actions/checkout@v7.0.1 + - uses: actions/setup-dotnet@v6.1.0 with: dotnet-version: 10.0.x - name: テスト @@ -34,8 +34,8 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 - - uses: actions/setup-dotnet@v6 + - uses: actions/checkout@v7.0.1 + - uses: actions/setup-dotnet@v6.1.0 with: dotnet-version: 10.0.x - name: バージョン @@ -50,7 +50,7 @@ jobs: fi - name: パッケージ作成 run: dotnet pack ZipConvertCustomerBarCode.sln -c Release -o artifacts -p:Version=${{ steps.version.outputs.version }} - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@v7.0.2 with: name: packages path: artifacts/ @@ -64,16 +64,16 @@ jobs: permissions: id-token: write # Trusted Publishing の短期間の API キーを取得するため steps: - - uses: actions/download-artifact@v8 + - uses: actions/download-artifact@v8.0.2 with: name: packages path: artifacts - - uses: actions/setup-dotnet@v6 + - uses: actions/setup-dotnet@v6.1.0 with: dotnet-version: 10.0.x - name: NuGet ログイン(Trusted Publishing) id: login - uses: NuGet/login@v1 + uses: NuGet/login@v1.2.0 with: user: ${{ secrets.NUGET_USER }} # release Environment の Secret。nuget.org のユーザー名(プロフィール名。メールアドレスではない) - name: nuget.org に公開 diff --git a/.github/workflows/verify-lockfile.yml b/.github/workflows/verify-lockfile.yml new file mode 100644 index 0000000..1a2a2af --- /dev/null +++ b/.github/workflows/verify-lockfile.yml @@ -0,0 +1,29 @@ +# .github/workflows/actions.lock がワークフローと食い違っている場合や、 +# ロックしたコミットが上流で確認できなくなった場合に失敗する +# (github/gh-actions-lock の verify-lockfile.yml をもとに、週1回の定期実行を追加している) + +name: verify-lockfile + +on: + pull_request: + push: + branches: + - master + # PR や push がない期間も、ロックしたタグが上流で付け替えられていないかを確認する + schedule: + - cron: '0 0 * * 1' + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - run: gh extension install github/gh-actions-lock --pin v0.4.1 + - run: gh actions-lock --verify diff --git a/CLAUDE.md b/CLAUDE.md index 0834aa5..88e8d52 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,6 +34,7 @@ - `.github/workflows/build.yml`: push・PR で Ubuntu と Windows × コアの両方のビルドをテストし、パッケージを作る。 - リリースは `v2.0.0` のようなタグを push すると、タグのバージョンで3パッケージを nuget.org に公開する(Trusted Publishing。ワークフローのファイル名 `build.yml` と Environment 名 `release` を nuget.org に登録しているので、どちらも名前を変えない)。 - 公開ジョブは GitHub の `release` Environment で動く(`v*` タグのみ、cssho の承認後に実行。Secret `NUGET_USER` もこの Environment にある)。`Directory.Build.props` の `Version` はローカル用で、公開時はタグが優先される。 +- ワークフローのアクションは `.github/workflows/actions.lock`(`gh actions-lock`)でコミットに固定している。`uses:` を追加・変更したら `gh actions-lock` でロックし直し、`gh actions-lock --verify` で確認してから、ロックファイルとワークフローを一緒にコミットする。CI の `verify-lockfile.yml` が PR・push・週1回で検証する。アクションの更新は Dependabot(`.github/dependabot.yml`、リリースから7日待つ)が、ロックファイルの作り直しも含めて PR にする。 - パッケージ作成時の検証(`EnablePackageValidation`)で、net8.0 版から netstandard2.0 版の公開 API が欠けているとエラー(CP0002)になる。 ## コード規約 From eb2dd77dd3346caa52be14baee4d2876a7fc515c Mon Sep 17 00:00:00 2001 From: cssho Date: Fri, 6 Nov 2026 08:58:32 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Dependabot=20=E3=81=AE=20cooldown=20?= =?UTF-8?q?=E3=82=92=E6=97=A2=E5=AE=9A(3=E6=97=A5)=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE --- .github/dependabot.yml | 4 +--- CLAUDE.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 38bafdf..d4ee88a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,9 @@ # GitHub Actions のアクションの更新 # ワークフローは actions.lock でロックしているが、Dependabot は更新の PR でロックファイルも作り直す +# 新しいリリースは、Dependabot の既定(cooldown 3日)で、リリースから3日経ってから更新する version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weekly - # 出たばかりのリリースは、問題(乗っ取りなど)が見つかる前に取り込まないよう7日待つ(既定は3日) - cooldown: - default-days: 7 diff --git a/CLAUDE.md b/CLAUDE.md index 88e8d52..7096ecf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,7 +34,7 @@ - `.github/workflows/build.yml`: push・PR で Ubuntu と Windows × コアの両方のビルドをテストし、パッケージを作る。 - リリースは `v2.0.0` のようなタグを push すると、タグのバージョンで3パッケージを nuget.org に公開する(Trusted Publishing。ワークフローのファイル名 `build.yml` と Environment 名 `release` を nuget.org に登録しているので、どちらも名前を変えない)。 - 公開ジョブは GitHub の `release` Environment で動く(`v*` タグのみ、cssho の承認後に実行。Secret `NUGET_USER` もこの Environment にある)。`Directory.Build.props` の `Version` はローカル用で、公開時はタグが優先される。 -- ワークフローのアクションは `.github/workflows/actions.lock`(`gh actions-lock`)でコミットに固定している。`uses:` を追加・変更したら `gh actions-lock` でロックし直し、`gh actions-lock --verify` で確認してから、ロックファイルとワークフローを一緒にコミットする。CI の `verify-lockfile.yml` が PR・push・週1回で検証する。アクションの更新は Dependabot(`.github/dependabot.yml`、リリースから7日待つ)が、ロックファイルの作り直しも含めて PR にする。 +- ワークフローのアクションは `.github/workflows/actions.lock`(`gh actions-lock`)でコミットに固定している。`uses:` を追加・変更したら `gh actions-lock` でロックし直し、`gh actions-lock --verify` で確認してから、ロックファイルとワークフローを一緒にコミットする。CI の `verify-lockfile.yml` が PR・push・週1回で検証する。アクションの更新は Dependabot(`.github/dependabot.yml`、既定の cooldown でリリースから3日待つ)が、ロックファイルの作り直しも含めて PR にする。 - パッケージ作成時の検証(`EnablePackageValidation`)で、net8.0 版から netstandard2.0 版の公開 API が欠けているとエラー(CP0002)になる。 ## コード規約