-
Notifications
You must be signed in to change notification settings - Fork 5
138 lines (119 loc) · 4.48 KB
/
release.yaml
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
name: "📦 Release"
on:
workflow_dispatch:
inputs:
bump:
description: "version bump method: major, minor, patch"
type: choice
options:
- major
- minor
- patch
required: true
default: patch
jobs:
publish:
name: 📦 Release
runs-on: ubuntu-latest
steps:
- name: 🧾 Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: "recursive"
fetch-depth: 0 # So we can get all tags.
- name: 🔎 Read Current Project Version
id: current-version
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: "0.0.0-devbuild"
- name: 🖨 Print Current Version
run: |
echo "Current Version: ${{ steps.current-version.outputs.tag }}"
- name: 🧮 Compute Next Version
uses: chickensoft-games/next-godot-csproj-version@v1
id: next-version
with:
project-version: ${{ steps.current-version.outputs.tag }}
godot-version: global.json
bump: ${{ inputs.bump }}
- name: ✨ Print Next Version
run: |
echo "Next Version: ${{ steps.next-version.outputs.version }}"
# Write version to file so .NET will build correct version.
- name: 📝 Write Version to File
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "0.0.0-devbuild"
replace: ${{ steps.next-version.outputs.version }}
regex: false
include: Chickensoft.AutoInject/Chickensoft.AutoInject.csproj
- name: 🖨 Copy Source to Source-Only package
run: |
# Copy source files from Chickensoft.AutoInject.Tests/src/**/*.cs
# to Chickensoft.AutoInject/src/**/*.cs
#
# Because source-only packages are hard to develop and test, we
# actually keep the source that goes in the source-only package inside
# the test project to make it easier to develop and test.
#
# we can always copy it right before publishing the package.
mkdir -p Chickensoft.AutoInject/src
cp -v -r Chickensoft.AutoInject.Tests/src/* Chickensoft.AutoInject/src/
- name: 🤐 Suppress Warnings From Files
run: |
# Define the multiline prefix and suffix
PREFIX="#pragma warning disable
#nullable enable
"
SUFFIX="
#nullable restore
#pragma warning restore"
# Function to add prefix and suffix to a file
add_prefix_suffix() {
local file="$1"
# Create a temporary file
tmp_file=$(mktemp)
# Add prefix, content of the file, and suffix to the temporary file
{
echo "$PREFIX"
cat "$file"
echo "$SUFFIX"
} > "$tmp_file"
# Move the temporary file to the original file
mv "$tmp_file" "$file"
}
# Export the function and variables so they can be used by find
export -f add_prefix_suffix
export PREFIX
export SUFFIX
# Find all files and apply the function
find Chickensoft.AutoInject/src -type f -name "*.cs" -exec bash -c 'add_prefix_suffix "$0"' {} \;
- name: 💽 Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
# Use the .NET SDK from global.json in the root of the repository.
global-json-file: global.json
- name: 🛠 Build Source-Only Package
working-directory: Chickensoft.AutoInject
run: |
dotnet build -c Release
- name: 🔎 Get Package Path
id: package-path
run: |
package=$(find ./Chickensoft.AutoInject/nupkg -name "*.nupkg")
echo "package=$package" >> "$GITHUB_OUTPUT"
echo "📦 Found package: $package"
- name: ✨ Create Release
env:
GITHUB_TOKEN: ${{ secrets.GH_BASIC }}
run: |
version="${{ steps.next-version.outputs.version }}"
gh release create --title "v$version" --generate-notes "$version" \
"${{ steps.package-path.outputs.package }}"
- name: 🛜 Publish to Nuget
run: |
dotnet nuget push "${{ steps.package-path.outputs.package }}" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source "https://api.nuget.org/v3/index.json" --skip-duplicate