diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d4ee88a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +# GitHub Actions のアクションの更新 +# ワークフローは actions.lock でロックしているが、Dependabot は更新の PR でロックファイルも作り直す +# 新しいリリースは、Dependabot の既定(cooldown 3日)で、リリースから3日経ってから更新する +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly 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 new file mode 100644 index 0000000..e78267b --- /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@v7.0.1 + - uses: actions/setup-dotnet@v6.1.0 + 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@v7.0.1 + - uses: actions/setup-dotnet@v6.1.0 + 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@v7.0.2 + 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@v8.0.2 + with: + name: packages + path: artifacts + - uses: actions/setup-dotnet@v6.1.0 + with: + dotnet-version: 10.0.x + - name: NuGet ログイン(Trusted Publishing) + id: login + uses: NuGet/login@v1.2.0 + 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/.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 c5b67b9..7096ecf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,6 +27,15 @@ - 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` はローカル用で、公開時はタグが優先される。 +- ワークフローのアクションは `.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)になる。 ## コード規約 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 @@ + +