Repository navigation
134 lines (112 loc) · 4.35 KB
/
Copy pathrelease-v1.yml
File metadata and controls
134 lines (112 loc) · 4.35 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
name: Release v1
on:
workflow_dispatch:
inputs:
version:
description: Stable semantic version (for example, 1.46.2)
required: true
type: string
permissions:
contents: write
concurrency:
group: release-v1
cancel-in-progress: false
env:
RELEASE_BRANCH: v1.x-maintenance
PROJECT_PATH: src/MiniExcel/MiniExcelLibs.csproj
OUTPUT_PATH: artifacts/release
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out v1 maintenance branch
uses: actions/checkout@v4
with:
ref: v1.x-maintenance
fetch-depth: 0
- name: Validate version
shell: pwsh
env:
VERSION: ${{ inputs.version }}
run: |
if ($env:VERSION -notmatch '^\d+\.\d+\.\d+$') {
throw "Version must use stable semantic version format, for example 1.46.2."
}
if (git tag --list $env:VERSION) {
throw "Tag $env:VERSION already exists."
}
- name: Update package and citation metadata
shell: pwsh
env:
VERSION: ${{ inputs.version }}
run: |
$utf8WithBom = [Text.UTF8Encoding]::new($true)
$utf8WithoutBom = [Text.UTF8Encoding]::new($false)
$project = [IO.File]::ReadAllText($env:PROJECT_PATH)
$projectVersionPattern = [regex]::new('(?m)(<Version>)[^<]+(</Version>)')
$project = $projectVersionPattern.Replace(
$project, "`${1}$env:VERSION`${2}", 1)
[IO.File]::WriteAllText($env:PROJECT_PATH, $project, $utf8WithBom)
$citationPath = 'CITATION.cff'
$citation = [IO.File]::ReadAllText($citationPath)
$citationVersionPattern = [regex]::new('(?m)^version:\s*.*$')
$citationDatePattern = [regex]::new('(?m)^date-released:\s*.*$')
$citation = $citationVersionPattern.Replace(
$citation, "version: $env:VERSION", 1)
$citation = $citationDatePattern.Replace(
$citation,
"date-released: `"$([DateTime]::UtcNow.ToString('yyyy-MM-dd'))`"",
1)
[IO.File]::WriteAllText($citationPath, $citation, $utf8WithoutBom)
$changedFiles = @(git diff --name-only)
$expectedFiles = @('CITATION.cff', $env:PROJECT_PATH)
$unexpectedFiles = @($changedFiles | Where-Object { $_ -notin $expectedFiles })
if ($unexpectedFiles.Count -gt 0) {
throw "Unexpected files changed: $($unexpectedFiles -join ', ')"
}
foreach ($expectedFile in $expectedFiles) {
if ($expectedFile -notin $changedFiles) {
throw "Expected metadata update missing for $expectedFile."
}
}
git diff --check
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore MiniExcel.slnx
- name: Test release candidate
run: dotnet test MiniExcel.slnx --configuration Release --no-restore --verbosity normal
- name: Pack release assets
run: dotnet pack "$PROJECT_PATH" --configuration Release --no-restore --output "$OUTPUT_PATH"
- name: Commit release metadata
env:
VERSION: ${{ inputs.version }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add CITATION.cff "$PROJECT_PATH"
git commit -m "chore: prepare $VERSION release"
git push origin "HEAD:$RELEASE_BRANCH"
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
gh release create "$VERSION" "$OUTPUT_PATH"/*.nupkg \
--repo "$GITHUB_REPOSITORY" \
--target "$RELEASE_BRANCH" \
--title "MiniExcel $VERSION" \
--generate-notes \
--latest
- name: Summarize release
env:
VERSION: ${{ inputs.version }}
run: |
echo "### MiniExcel $VERSION published" >> "$GITHUB_STEP_SUMMARY"
echo "Zenodo will archive this release and assign its version DOI automatically." >> "$GITHUB_STEP_SUMMARY"
echo "Concept DOI: https://doi.org/10.5281/zenodo.22054705" >> "$GITHUB_STEP_SUMMARY"