1- name : package workflow
1+ name : release workflow
22
33on :
44 push :
5- paths-ignore :
6- - ' **/*.md'
7- - ' **/*.yml'
8- tags :
5+ tags :
96 - ' v-*'
10- workflow_dispatch :
7+ workflow_dispatch :
8+ inputs :
9+ tag :
10+ description : Existing v-* tag to release
11+ required : true
12+ type : string
13+
14+ permissions :
15+ contents : read
16+
17+ env :
18+ RELEASE_TAG : ${{ inputs.tag || github.ref_name }}
19+
1120jobs :
1221 build-reactapp :
1322 runs-on : ubuntu-latest
@@ -19,13 +28,15 @@ jobs:
1928 node-version : [16.x]
2029
2130 steps :
22- - uses : actions/checkout@v2
31+ - uses : actions/checkout@v4
32+ with :
33+ ref : ${{ env.RELEASE_TAG }}
2334 - name : Use Node.js ${{ matrix.node-version }}
24- uses : actions/setup-node@v1
35+ uses : actions/setup-node@v4
2536 with :
2637 node-version : ${{ matrix.node-version }}
27-
28- - run : npm install
38+
39+ - run : npm ci
2940 - run : npm run build
3041 - uses : actions/upload-artifact@v4
3142 with :
@@ -34,39 +45,82 @@ jobs:
3445 build-dotnet :
3546 needs : build-reactapp
3647 runs-on : ubuntu-latest
48+ permissions :
49+ contents : write
3750
3851 steps :
3952 - uses : actions/checkout@v4
53+ with :
54+ fetch-depth : 0
55+ ref : ${{ env.RELEASE_TAG }}
4056 - name : setup .net
4157 uses : actions/setup-dotnet@v4
4258 with :
43- dotnet-version : |
59+ dotnet-version : |
4460 8.0.x
4561 9.0.x
4662 10.0.x
63+ - name : Validate release version
64+ id : release-info
65+ shell : bash
66+ env :
67+ PROJECT_FILE : src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj
68+ run : |
69+ if [[ "$RELEASE_TAG" != v-* ]]; then
70+ echo "Release tag must start with v-. Got: $RELEASE_TAG" >&2
71+ exit 1
72+ fi
73+
74+ tag_version="${RELEASE_TAG#v-}"
75+ project_version="$(dotnet msbuild "$PROJECT_FILE" -getProperty:Version -nologo | xargs)"
76+
77+ if [[ "$tag_version" != "$project_version" ]]; then
78+ echo "Tag version $tag_version does not match project version $project_version." >&2
79+ exit 1
80+ fi
81+
82+ prerelease=false
83+ if [[ "$tag_version" == *-* ]]; then
84+ prerelease=true
85+ fi
86+
87+ previous_tag="$(git describe --tags --abbrev=0 "$RELEASE_TAG^" --match 'v-*')"
88+
89+ echo "version=$tag_version" >> "$GITHUB_OUTPUT"
90+ echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
91+ echo "previous_tag=$previous_tag" >> "$GITHUB_OUTPUT"
4792 - name : Install dependencies
4893 run : dotnet restore
4994 - name : Build
5095 run : dotnet build --configuration Release --no-restore
96+ - name : Test
97+ run : dotnet test --configuration Release --no-build --verbosity normal
5198 - uses : actions/download-artifact@v4
5299 with :
53100 name : agileconfig-ui
54101 path : src/AgileConfig.Server.Apisite/wwwroot/ui
55- - name : build server release xxx
56- run : dotnet publish src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj -c Release
57- - uses : vimtor/action-zip@v1
58- with :
59- files : src/AgileConfig.Server.Apisite/bin/Release/net10.0/publish/
60- dest : agileconfig_server_deploy.zip
61- - name : create release
62- uses : ncipollo/release-action@v1
63- with :
64- artifacts : agileconfig_server_deploy.zip
65- token : ${{ secrets.GITHUB_TOKEN }}
66- - name : Push to Docker hub release -xxx
102+ - name : Publish server
103+ run : dotnet publish src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj --configuration Release --no-restore
104+ - name : Package server
105+ working-directory : src/AgileConfig.Server.Apisite/bin/Release/net10.0/publish
106+ env :
107+ VERSION : ${{ steps.release-info.outputs.version }}
108+ run : zip -r "$GITHUB_WORKSPACE/agileconfig-server-$VERSION.zip" .
109+ - name : Push version image to Docker Hub
67110 uses : docker/build-push-action@v1
68111 with :
69112 username : ${{ secrets.DOCKER_HUB_NAME }}
70113 password : ${{ secrets.DOCKER_HUB_PASSWORD }}
71114 repository : kklldog/agile_config
72- tag_with_ref : true
115+ tags : ${{ env.RELEASE_TAG }}
116+ - name : Create GitHub release
117+ uses : ncipollo/release-action@v1
118+ with :
119+ artifacts : agileconfig-server-${{ steps.release-info.outputs.version }}.zip
120+ generateReleaseNotes : true
121+ generateReleaseNotesPreviousTag : ${{ steps.release-info.outputs.previous_tag }}
122+ makeLatest : ${{ steps.release-info.outputs.prerelease == 'false' }}
123+ name : ${{ env.RELEASE_TAG }}
124+ prerelease : ${{ steps.release-info.outputs.prerelease }}
125+ tag : ${{ env.RELEASE_TAG }}
126+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments