diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ca60fab --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,43 @@ +name: publish + +on: + push: + branches: + - master + paths: + - 'src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj' + +jobs: + check-bump-version: + runs-on: ubuntu-latest + outputs: + new-version: ${{ steps.diff.outputs.version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 200 + - name: Get version from csproj + run: | + version="$(grep -o --color=never "[0-9]\+\.[0-9]\+\.[0-9]\+" src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj | sed 's///')" + echo "version=$version" >> "$GITHUB_OUTPUT" + id: diff + + publish: + needs: check-bump-version + if: ${{ needs.check-bump-version.outputs.new-version }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Setup .NET + uses: actions/setup-dotnet@main + with: + dotnet-version: '5.0.x' + + - name: dotnet build + run: dotnet build ./Dena.CodeAnalysis.Testing.sln --configuration Release + + - name: Create NuPkg + run: dotnet pack ./src/Dena.CodeAnalysis.Testing --include-symbols --configuration Release -o ./nupkg + + - name: Publish NuPkg + run: dotnet nuget push ./nupkg/Dena.CodeAnalysis.Testing.*.symbols.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} diff --git a/publish b/publish deleted file mode 100755 index 14a1349..0000000 --- a/publish +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -set -euo pipefail - -BASE_DIR="$(cd "$(dirname "$0")"; pwd)" -NUPKG_BASENAME='Dena.CodeAnalysis.Testing.nupkg' - - -throw() { - local msg="$*" - printf '%s\n' "$msg" 1>&2 - false -} - - -has() { - local cmd="$1" - which "$cmd" >/dev/null 2>&1 -} - - -usage() { - cat - 1>&2 <<-EOS -usage: publish [] - -OPTIONS - -h, --help print this help -EOS -} - - -get-version() { - (cd "$BASE_DIR" - grep -o '[^<]*' ./src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj | sed 's/\([^<]*\).*/\1/' - ) -} - - -validate-env() { - has dotnet || throw "dotnet must be installed (see https://docs.microsoft.com/ja-jp/dotnet/core/tools/)" - has nuget || throw "nuget must be installed (see https://docs.microsoft.com/ja-jp/nuget/install-nuget-client-tools)" -} - - -acquire-tag() { - (cd "$BASE_DIR" - local version="$1" - if (git tag | grep -Fqx "$version"); then - throw "a tag has the same name exists on local, so if still you want to overwrite the tag, please remove the tag on local and try again.: '$version'" - fi - git tag "$version" - ) -} - - -build() { - local dst="$1" - local version="$2" - - (cd "$BASE_DIR" - dotnet build --no-incremental - - local nupkg_orig - nupkg_orig="./src/Dena.CodeAnalysis.Testing/bin/Debug/Dena.CodeAnalysis.Testing.${version}.nupkg" - [[ -f "$nupkg_orig" ]] || throw "no .nupkg found at '$nupkg_orig'" - - cp "$nupkg_orig" "$dst" - ) -} - - -main() { - local arg="${1:-}" - if [[ "$arg" == "--help" ]] || [[ "$arg" == "-h" ]]; then - usage - false - fi - if [[ "$arg" == "--version" ]] || [[ "$arg" == "-v" ]]; then - get-version - exit 0 - fi - - validate-env - - local version - version="$(get-version)" - acquire-tag "$version" - - local nupkg="./${NUPKG_BASENAME}" - build "$nupkg" "$version" - - nuget push "$nupkg" -Source https://api.nuget.org/v3/index.json - git push origin "$version" -} - - -main "$@" diff --git a/src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj b/src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj index 3bff4d1..3e99b3d 100644 --- a/src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj +++ b/src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj @@ -9,7 +9,7 @@ Dena.CodeAnalysis.Testing - 3.0.3 + 3.0.4 Kazuma Inagaki, Koji Hasegawa, Kuniwak false Test helpers for DiagnosticAnalyzers