Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
@@ -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
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions .github/workflows/verify-lockfile.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)になる。

## コード規約

Expand Down
30 changes: 28 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<Project>

<PropertyGroup>
<!-- CI ではタグ(v2.0.0 など)のバージョンを -p:Version で指定する -->
<Version>2.0.0</Version>
<Company>Toshiba</Company>
<Authors>cssho</Authors>
<Product>ZipConvertCustomerBarCode</Product>
<Copyright>Copyright © Toshiba 2015</Copyright>
<Copyright>Copyright (c) 2015 cssho</Copyright>
</PropertyGroup>

<!-- NuGet パッケージ -->
<PropertyGroup>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/cssho/ZipConvertCustomerBarCode</PackageProjectUrl>
<RepositoryUrl>https://github.com/cssho/ZipConvertCustomerBarCode</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>customer-barcode;barcode;japan-post;postal-code;zipcode;カスタマバーコード;郵便番号</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!--
パッケージ作成時に、net8.0 版が netstandard2.0 版の公開 API をすべて持っているかを確認する
(#if で net8.0 版から API が欠けるとエラー CP0002。net8.0 版にだけ API を足すのは検出しない)
-->
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath="\" Visible="false" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<ItemGroup>
<PackageReference Include="xunit.v3" Version="4.0.2" />
<!-- Linux(CI)で SkiaSharp のテストを動かすためのネイティブライブラリ -->
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="4.154.0" />
<Using Include="Xunit" />
</ItemGroup>

Expand Down
Loading