From 231b91aa4687227f5965536ec0aa636a7d475b7a Mon Sep 17 00:00:00 2001 From: newbe36524 Date: Sun, 25 Jul 2021 14:06:33 +0800 Subject: [PATCH] add github action --- .github/labeler.yml | 4 ++ .github/release-drafter.yml | 43 ++++++++++++++++++ .github/workflows/labeler.yml | 11 +++++ .github/workflows/main.yml | 39 ++++++++++++++++ .github/workflows/release-drafter.yml | 29 ++++++++++++ .github/workflows/release.yml | 65 +++++++++++++++++++++++++++ GitVersion.yml | 3 ++ 7 files changed, 194 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release.yml create mode 100644 GitVersion.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..9467aa7 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,4 @@ +# Configuration for labeler - https://github.com/actions/labeler + +🛠 Improvement: FastGithub/**/* +Actions: .github/workflows/**/* diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..fedcef8 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,43 @@ +name-template: "v$RESOLVED_VERSION 🌈" +tag-template: "v$RESOLVED_VERSION" +categories: + - title: "💥 Breaking Changes" + label: "💥 Breaking Change" + + - title: "🌟 New Features" + label: "🌟 New Feature" + + - title: "⭐ Features" + label: "⭐ Feature" + + - title: "🐞 Bug Fixes" + label: "🐞 Bug Fix" + + - title: "🛠 Improvements" + label: "🛠 Improvement" + + - title: "🌀 External Changes" + label: "🔌 3rd Party Plugin" + + - title: "📖 Documentation" + label: "📖 Docs" + + - title: "🌍 Localization" + label: "🌍 i18n" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - "major" + minor: + labels: + - "minor" + patch: + labels: + - "patch" + default: patch +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..27719aa --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,11 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v3 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f6d5dd5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: Amazing Favorites build + +on: + push: + branches: + - master + - develop + - feature/ci + - feature/ut + + pull_request: + branches: + - master + - develop + +jobs: + build: + runs-on: ubuntu-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + include-prerelease: true + + - name: Install dependencies + run: | + cd . + dotnet restore + - name: build and test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + run: | + dotnet build . --configuration Release diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..442f6dc --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,29 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # with: + # config-name: my-config.yml + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8598510 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Release + +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + strategy: + matrix: + os: [win-x64, linux-x64, osx-x64] + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup .NET 3.0 for gitreleasemanager + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.x + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + include-prerelease: true + - name: Setup .NET 5.0 for Release Manager + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "5.0.x" + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.9 + with: + versionSpec: 5.x + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.9 + with: + useConfigFile: true + - name: Restore dependencies + run: | + cd $GITHUB_WORKSPACE/src + dotnet restore + - name: Build + run: | + cd $GITHUB_WORKSPACE/src + dotnet publish FastGithub -c Release -f net6.0 /p:PublishSingleFile=true /p:PublishTrimmed=true -r ${{ matrix.os }} /p:PublishTrimmed=true -p:AssemblyVersion=${{ steps.gitversion.outputs.MajorMinorPatch }} -p:Version=${{ steps.gitversion.outputs.SemVer }} -o ./out/${{ matrix.os }} + mv out/${{ matrix.os }} FastGithub-${{ matrix.os }}-${{ steps.gitversion.outputs.MajorMinorPatch }} + zip -r FastGithub-${{ matrix.os }}-${{ steps.gitversion.outputs.MajorMinorPatch }}.zip FastGithub-${{ matrix.os }}-${{ steps.gitversion.outputs.MajorMinorPatch }} + - uses: gittools/actions/gitreleasemanager/setup@v0.9.2 + name: Install GitReleaseManager + with: + versionSpec: "0.11.x" + + - uses: gittools/actions/gitreleasemanager/addasset@v0.9.2 + name: Add asset to a release with GitReleaseManager + with: + token: ${{ secrets.GITHUB_TOKEN }} + owner: "newbe36524" + repository: "FastGithub" + tagName: "v${{ steps.gitversion.outputs.MajorMinorPatch }}" + assets: | + src/FastGithub-${{ matrix.os }}-${{ steps.gitversion.outputs.MajorMinorPatch }}.zip diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..5a33b82 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,3 @@ +major-version-bump-message: "(breaking|major):" +minor-version-bump-message: "(feature|minor):" +patch-version-bump-message: "(fix|patch):"