Skip to content

Commit

Permalink
ci(.github/workflows/hangfireplugin): add
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Dec 27, 2023
1 parent 4c14501 commit e42d0d2
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/HangfirePlugin-nuget-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: HangfirePlugin NuGet Push

on:
push:
tags:
- 'HangfirePlugin-v*'

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v1

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Build and Pack
run: |
cd ./plugins/HangfirePlugin
dotnet build --configuration Release
dotnet pack --configuration Release
dotnet pack --configuration Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
ls
ls ./bin/Release/
- name: Install Nuget
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'

- name: Add private GitHub registry to NuGet
run: |
nuget sources add -name github -Source https://nuget.pkg.github.com/yiyungent/index.json -Username yiyungent -Password ${{ secrets.GITHUB_TOKEN }}
- name: Push generated package to GitHub registry and NuGet
run: |
nuget push .\plugins\HangfirePlugin\bin\Release\*.nupkg -Source github -SkipDuplicate
nuget push .\plugins\HangfirePlugin\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.PLUGINCORE_NUGET_KEY }}
73 changes: 73 additions & 0 deletions .github/workflows/HangfirePlugin-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: HangfirePlugin Release

on:
push:
tags:
- 'HangfirePlugin-v*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2
with:
# 为了让 git 有日志 (git log) 可寻,还得在检出的时候顺带把所有提交历史一并拉下来,指定 fetch-depth 就能做到
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Set outputs
id: vars
run: |
tagPrefix=refs/tags/HangfirePlugin-
# 获取字符串长度
tagPrefixLen=${#tagPrefix}
# 去掉前面的 refs/tags/HangfirePlugin-
RELEASE_VERSION=${GITHUB_REF:$tagPrefixLen}
# 提取出 v1.0.0
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
shell: bash

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Build
run: |
cd ./plugins/HangfirePlugin
dotnet build --configuration Release
ls
ls ./bin/Release/
ls ./bin/Release/net6.0/
shell: bash

- name: Zip the Build
run: |
cd ./plugins/HangfirePlugin/bin/Release/net6.0
zip -r HangfirePlugin-${{ steps.vars.outputs.RELEASE_VERSION }}-net6.0.zip *
shell: bash

- name: Create temp-release-note.md
run: |
cp utils/generate-release-note.ps1 generate-release-note.ps1
$env:GitProjectTagName="HangfirePlugin"
$env:GitProjectPath="plugins/HangfirePlugin/*"
./generate-release-note.ps1
shell: pwsh

- name: Create Release and Upload Release Asset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
#tag_name: ${{ github.ref }}
#name: ${{ github.ref }}
# body: TODO New Release.
body_path: temp-release-note.md
draft: false
prerelease: false
files: |
./plugins/HangfirePlugin/bin/Release/net6.0/HangfirePlugin-${{ steps.vars.outputs.RELEASE_VERSION }}-net6.0.zip
./plugins/HangfirePlugin/README.md
./plugins/HangfirePlugin/LICENSE

0 comments on commit e42d0d2

Please sign in to comment.