-
-
Notifications
You must be signed in to change notification settings - Fork 4
62 lines (47 loc) · 1.76 KB
/
release.yml
File metadata and controls
62 lines (47 loc) · 1.76 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
name: release
on:
push:
branches:
- "main"
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set VERSION variable
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# For tag pushes, use the tag version directly
VERSION=${GITHUB_REF/refs\/tags\//}
else
git fetch --tags # Ensure all tags are fetched
# Get the latest base tag (e.g., "0.1.0")
LATEST_TAG=$(git describe --tags --abbrev=0)
# Get the current week using Monday as the first day
WEEK=$(date +'%W')
WEEK=$((10#$WEEK))
YEAR=$(date +'%Y')
# Calculate Monday of the current week (works on GNU date)
MONDAY=$(date -d "today - $(($(date +%u)-1)) days" +%Y-%m-%d)
# Count the number of commits made since Monday
BUILD_NUMBER=$(git rev-list --count HEAD --since="$MONDAY")
# Construct the version string with the commit count as the build number
VERSION="${LATEST_TAG}-preview.${YEAR}.${WEEK}.${BUILD_NUMBER}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build /p:CiVersion=${VERSION} --configuration Release --no-restore
- name: Pack
run: dotnet pack --configuration Release --no-build --output bin
- name: Push (allow overwriting)
run: dotnet nuget push bin/*.nupkg --source="https://api.nuget.org/v3/index.json" --api-key ${{secrets.NUGET_API_KEY}}