rnmmp #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'CHANGELOG.md' | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} | |
OWNER_NAME: ${{ github.repository_owner }} | |
REPO_NAME: ${{ github.event.repository.name }} | |
OWNER_ID: ${{ github.event.repository.owner.node_id }} | |
REPO_ID: ${{ github.event.repository.node_id }} | |
PR_ID: ${{ github.event.pull_request.node_id }} | |
PROJECT_NAME: ${{ github.event.repository.name }}_VNext | |
concurrency: ci-${{ github.ref }} | |
jobs: | |
#Get Version | |
prepare_check: | |
runs-on: ubuntu-latest | |
env: | |
WORKER_NAME: VERSION_SCANNER | |
outputs: | |
releaseVersion: ${{steps.scanner.outputs.RELEASE_VERSION}} | |
releasePackString: ${{steps.outter.outputs.RELEASE_PACK_STRING}} | |
hasNugetKey: ${{steps.outter.outputs.HAS_NUGET_KEY}} | |
hasCoverageKey: ${{steps.outter.outputs.HAS_COVERAGE_KEY}} | |
steps: | |
- uses: actions/checkout@v4 | |
#- name: 🔨 Setup .NET 6.X SDK | |
# uses: actions/setup-dotnet@v3 | |
# with: | |
# dotnet-version: '6.x' | |
- name: 📡 Scan Prepare Enviroment | |
id: scanner | |
run: dotnet test './test/workflow/Workflow.Runner' --nologo -c Release | |
- name: 🙂 Output ReleaseVersion | |
id: outter | |
run: | | |
if [ "${{ steps.scanner.outputs.RELEASE_VERSION }}" == "" ]; then | |
echo "未扫描到版本号,请核对 CHANGELOD 文档!" | |
exit 1 | |
fi | |
echo "RELEASE_PACK_STRING=${{github.event.repository.name}}_Release_v${{ steps.scanner.outputs.RELEASE_VERSION }}" >> "$GITHUB_OUTPUT" | |
if [ "${{ secrets.NUGET_KEY }}" == "" ]; then | |
echo "HAS_NUGET_KEY=false" >> $GITHUB_OUTPUT | |
else | |
echo "HAS_NUGET_KEY=true" >> $GITHUB_OUTPUT | |
fi | |
#Archive Project | |
archive_project: | |
runs-on: ubuntu-latest | |
needs: prepare_check | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} | |
PROJECT_ARCHIVE_NAME: ${{ needs.prepare_check.outputs.releasePackString }} | |
WORKER_NAME: PROJECT_ARCHIVE | |
steps: | |
- uses: actions/checkout@v4 | |
#- name: 🔨 Setup .NET 6.X SDK | |
# uses: actions/setup-dotnet@v3 | |
# with: | |
# dotnet-version: '6.x' | |
- name: 📄 Achive Project | |
run: dotnet test './test/workflow/Workflow.Runner' --nologo -c Release | |
publish: | |
runs-on: ubuntu-latest | |
needs: prepare_check | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 🔨 Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
3.1.x | |
5.0.x | |
6.0.x | |
7.0.x | |
8.0.x | |
9.0.x | |
- name: ✊ Release Dll | |
run: dotnet build -c Release | |
- name: 🚦 Check & Pack Nuget | |
run: dotnet test './test/workflow/Workflow.Nuget.Publish' --nologo --no-restore --no-build -c Release | |
- name: 📶 Push to Nuget | |
if: ${{ needs.prepare_check.outputs.hasNugetKey == 'true' }} | |
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate | |
release: | |
runs-on: ubuntu-latest | |
needs: prepare_check | |
env: | |
RELEASE_VERSION: ${{needs.prepare_check.outputs.releaseVersion}} | |
PACK_STRING: ${{needs.prepare_check.outputs.releasePackString}} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 🎉 Release | |
run: | | |
RELEASE_ID=$(gh api graphql -H "X-Github-Next-Global-ID: 1" -f query=' | |
query{ | |
repository(owner:"${{github.repository_owner}}",name:"${{github.event.repository.name}}"){ | |
release(tagName:"v${{env.RELEASE_VERSION}}"){ | |
id | |
} | |
} | |
}' --jq '.data.repository.release.id') | |
RESULT=0 | |
if [ "$RELEASE_ID" != "" ]; then | |
if [ "$RELEASE_ID" != "null" ]; then | |
RESULT=1 | |
fi | |
fi | |
if [ $RESULT == 0 ]; then | |
echo "::debug::no release package" | |
echo "不存在 Id ,开始创建 Release v${{env.RELEASE_VERSION}} 包!" | |
gh release create v${{env.RELEASE_VERSION}} -F CHANGELOG.md | |
else | |
echo "::debug::exist release package" | |
echo "该 Release v${{env.RELEASE_VERSION}} 包已存在!" | |
gh release edit v${{env.RELEASE_VERSION}} --notes-file CHANGELOG.md | |
fi |