-
Notifications
You must be signed in to change notification settings - Fork 10
119 lines (103 loc) · 3.63 KB
/
pack.yml
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
name: Pack
on:
workflow_call:
inputs:
build-ref:
required: true
type: string
workflow_dispatch:
inputs:
docs:
description: "Set to 'yes' to deploy docfx to GitHub Pages."
required: false
default: "no"
push:
# Deploy automatically on a new release, automatically publishes docfx to GitHub Pages
release:
types: [published]
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read
# Expose the docs version as a job-level output
outputs:
doc_version: ${{ steps.nbgv.outputs.AssemblyInformationalVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
lfs: true
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- uses: dotnet/[email protected]
id: nbgv
- run: dotnet restore src/FastBertTokenizer/FastBertTokenizer.csproj /p:ContinuousIntegrationBuild=true
- run: dotnet tool install -g docfx
- run: docfx docfx/docfx.json
- uses: actions/upload-artifact@v4
with:
name: FastBertTokenizer-docs-${{ steps.nbgv.outputs.AssemblyInformationalVersion }}
path: docfx/_site/**/*
# To be sure we don't pack the docfx build, this comes after docfx
- run: dotnet build src/FastBertTokenizer/FastBertTokenizer.csproj -c Release --no-restore /p:ContinuousIntegrationBuild=true
# Remove the html head with the logo from README for nupkg
- id: clean-readme
uses: sean0x42/markdown-extract@v2
with:
file: README.md
pattern: 'FastBertTokenizer'
- uses: "DamianReeves/write-file-action@master"
with:
path: README.md
write-mode: overwrite
contents: ${{ steps.clean-readme.outputs.markdown }}
- run: dotnet pack src/FastBertTokenizer/FastBertTokenizer.csproj -c Release --no-restore --no-build /p:ContinuousIntegrationBuild=true
- uses: actions/upload-artifact@v4
with:
name: FastBertTokenizer-nupkg-${{ steps.nbgv.outputs.AssemblyInformationalVersion }}
path: bin/Packages/Release/**/*
#########################################################################
# DEPLOY Docs Job (runs only if release event OR if "docs: yes" manually)
#########################################################################
deploy-docs:
# Condition:
# 1) if it's a RELEASE event, OR
# 2) if it's a manual dispatch with docs == 'yes'
# Otherwise, skip
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.docs == 'yes') }}
name: Deploy docfx to GitHub Pages
runs-on: ubuntu-22.04
needs: build
# Pages deployment requires these permissions
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: FastBertTokenizer-docs-${{ needs.build.outputs.doc_version }}
path: docs
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4