-
-
Notifications
You must be signed in to change notification settings - Fork 312
156 lines (133 loc) · 4.89 KB
/
Copy pathrelease.yml
File metadata and controls
156 lines (133 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release
on:
push:
tags: [v*]
env:
DOTNET_VERSION: 10.0.x
NODE_VERSION: 24.x
RELEASE_ASSET_NAME: acmebot.zip
permissions: {}
jobs:
validate-draft-release:
name: Validate draft release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check draft release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}
run: |
if ! gh release view "$TAG_NAME" > /dev/null 2>&1; then
echo "::error::Draft release $TAG_NAME does not exist. Create the tag and draft release manually before this workflow runs."
exit 1
fi
IS_DRAFT=$(gh release view "$TAG_NAME" --json isDraft --jq '.isDraft')
if [ "$IS_DRAFT" != "true" ]; then
echo "::error::Release $TAG_NAME is not a draft. Release assets must be uploaded before publishing immutable releases."
exit 1
fi
build:
name: Build release artifacts
needs: validate-draft-release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: src/Acmebot.App/ClientApp/package-lock.json
- name: Set release version
id: setup_version
run: |
FULL_VERSION=${GITHUB_REF_NAME#v}
echo "version=${FULL_VERSION}" >> "$GITHUB_OUTPUT"
- name: Build dashboard
working-directory: ./src/Acmebot.App/ClientApp
env:
ACMEBOT_VERSION: ${{ steps.setup_version.outputs.version }}
ACMEBOT_COMMIT_HASH: ${{ github.sha }}
run: |
npm ci
npm run build
- name: Publish backend
run: dotnet publish -c Release -o ./dist -p:Version=${{ steps.setup_version.outputs.version }} ./src/Acmebot.App
- name: Pack CLI
run: dotnet pack -c Release -o ./nupkg -p:Version=${{ steps.setup_version.outputs.version }} ./src/Acmebot.Cli
- name: Archive release asset
run: 7z a -mx=9 ${{ env.RELEASE_ASSET_NAME }} ./dist/* ./dist/.[^.]*
- name: Upload release asset artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-asset
path: ${{ env.RELEASE_ASSET_NAME }}
- name: Upload CLI package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cli-package
path: ./nupkg/*.nupkg
upload-release-asset:
name: Upload release asset
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download release asset artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-asset
path: .
- name: Upload release asset
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}
run: gh release upload "$TAG_NAME" "${{ env.RELEASE_ASSET_NAME }}" --clobber
publish-cli:
name: Publish CLI package
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Set up .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download CLI package artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: cli-package
path: ./nupkg
- name: Sign in to NuGet
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
id: nuget_login
with:
user: shibayan
- name: Publish CLI package to NuGet
run: dotnet nuget push ./nupkg/*.nupkg --api-key "${{ steps.nuget_login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
publish-release:
name: Publish release
needs: [upload-release-asset, publish-cli]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Publish draft release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}
run: gh release edit "$TAG_NAME" --draft=false