XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Added
.github/PUBLISHING.md
+45
-0
Added
.github/workflows/publish-packages.yml
+120
-0
Added
.github/workflows/validate.yml
+34
-0
XFEstudio/XFEExtension
添加github工作流
a305f2f
代码差异
3 个文件
+199
-0
@@ -0,0 +1,45 @@
1
# Publishing Packages
2
3
This repository now includes two GitHub Actions workflows:
4
5
- `Validate`: runs on `push` and `pull_request` to ensure the solution restores and builds cleanly.
6
- `Publish Packages`: runs when you push a tag that starts with `v`, for example `v3.0.9`, or when you trigger it manually from the Actions page.
7
8
## Required secrets
9
10
Add this repository secret before publishing to NuGet.org:
11
12
- `NUGET_API_KEY`: API key from NuGet.org with push permission for `XFEExtension.NetCore`
13
14
No extra secret is required for GitHub Packages. The workflow uses the built-in `GITHUB_TOKEN` and requests `packages: write`.
15
16
The same built-in `GITHUB_TOKEN` is also used to create the GitHub Release and upload package assets.
17
18
## Recommended release flow
19
20
1. Update the project and verify CI is green.
21
2. Push a version tag such as `v3.0.9`.
22
3. GitHub Actions will automatically do all of the following:
23
- build and pack the project
24
- upload the generated `.nupkg` as a workflow artifact
25
- publish the package to NuGet.org
26
- publish the package to GitHub Packages at `https://nuget.pkg.github.com/XFEstudio/index.json`
27
- create a GitHub Release for that tag
28
- attach the generated `.nupkg` files to the GitHub Release
29
30
## Tag-triggered release behavior
31
32
When you push a new tag like `v3.0.9`, that single action is the release trigger for the entire pipeline. You do not need to manually start the workflow afterward.
33
34
The release workflow is tied to `push.tags: v*`, so each new version tag automatically runs the full publishing flow.
35
36
## Manual publish
37
38
If you need to republish packages from the GitHub Actions UI:
39
40
1. Open `Publish Packages`.
41
2. Click `Run workflow`.
42
3. Fill in the `version` input.
43
4. Optionally set `skip_nuget_org` to `true` when you only want GitHub Packages.
44
45
Manual runs publish packages, but GitHub Release creation is only performed for real tag pushes so the release stays aligned with the repository tag history.
@@ -0,0 +1,120 @@
1
name: Publish Packages
2
3
on:
4
push:
5
tags:
6
- "v*"
7
workflow_dispatch:
8
inputs:
9
version:
10
description: Package version to publish, for example 3.0.9
11
required: true
12
type: string
13
skip_nuget_org:
14
description: Skip publishing to NuGet.org
15
required: false
16
default: false
17
type: boolean
18
19
permissions:
20
contents: write
21
packages: write
22
23
env:
24
DOTNET_VERSION: 10.0.x
25
SOLUTION_PATH: XFEExtension.slnx
26
PROJECT_PATH: XFEExtension.NetCore/XFEExtension.NetCore.csproj
27
PACKAGE_OUTPUT_DIR: ${{ github.workspace }}/artifacts/packages
28
29
jobs:
30
publish:
31
runs-on: ubuntu-latest
32
33
steps:
34
- name: Checkout
35
uses: actions/checkout@v4
36
with:
37
fetch-depth: 0
38
39
- name: Setup .NET
40
uses: actions/setup-dotnet@v4
41
with:
42
dotnet-version: ${{ env.DOTNET_VERSION }}
43
44
- name: Resolve version
45
id: version
46
shell: bash
47
run: |
48
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
49
version="${{ inputs.version }}"
50
else
51
version="${GITHUB_REF_NAME#v}"
52
fi
53
54
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?([-.][0-9A-Za-z.-]+)?$ ]]; then
55
echo "Invalid package version: $version"
56
exit 1
57
fi
58
59
echo "value=$version" >> "$GITHUB_OUTPUT"
60
echo "PACKAGE_VERSION=$version" >> "$GITHUB_ENV"
61
62
- name: Restore
63
run: dotnet restore ${{ env.SOLUTION_PATH }}
64
65
- name: Build
66
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
67
68
- name: Pack
69
run: dotnet pack ${{ env.PROJECT_PATH }} --configuration Release --no-build --no-restore --output ${{ env.PACKAGE_OUTPUT_DIR }} -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
70
71
- name: Upload package artifacts
72
uses: actions/upload-artifact@v4
73
with:
74
name: packages-${{ env.PACKAGE_VERSION }}
75
path: ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg
76
if-no-files-found: error
77
78
- name: Publish to GitHub Packages
79
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate
80
81
- name: Publish to NuGet.org
82
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.skip_nuget_org }}
83
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
84
85
- name: Create GitHub Release
86
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
87
uses: softprops/action-gh-release@v2
88
with:
89
tag_name: ${{ github.ref_name }}
90
name: XFEExtension.NetCore ${{ github.ref_name }}
91
generate_release_notes: true
92
append_body: true
93
body: |
94
## Package feeds
95
96
- NuGet.org
97
- GitHub Packages: `https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json`
98
files: ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg
99
fail_on_unmatched_files: true
100
prerelease: ${{ contains(env.PACKAGE_VERSION, '-') }}
101
102
- name: Publish summary
103
shell: bash
104
run: |
105
{
106
echo "## Published packages"
107
echo ""
108
echo "- Version: \`${PACKAGE_VERSION}\`"
109
echo "- GitHub Packages: published"
110
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.skip_nuget_org }}" == "true" ]]; then
111
echo "- NuGet.org: skipped"
112
else
113
echo "- NuGet.org: published"
114
fi
115
if [[ "${{ github.event_name }}" == "push" && "${GITHUB_REF_NAME}" == v* ]]; then
116
echo "- GitHub Release: created"
117
else
118
echo "- GitHub Release: skipped"
119
fi
120
} >> "$GITHUB_STEP_SUMMARY"
@@ -0,0 +1,34 @@
1
name: Validate
2
3
on:
4
push:
5
branches:
6
- master
7
- main
8
pull_request:
9
10
permissions:
11
contents: read
12
13
env:
14
DOTNET_VERSION: 10.0.x
15
SOLUTION_PATH: XFEExtension.slnx
16
17
jobs:
18
build:
19
runs-on: ubuntu-latest
20
21
steps:
22
- name: Checkout
23
uses: actions/checkout@v4
24
25
- name: Setup .NET
26
uses: actions/setup-dotnet@v4
27
with:
28
dotnet-version: ${{ env.DOTNET_VERSION }}
29
30
- name: Restore
31
run: dotnet restore ${{ env.SOLUTION_PATH }}
32
33
- name: Build
34
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true