-
Notifications
You must be signed in to change notification settings - Fork 5
168 lines (147 loc) · 6.31 KB
/
snapshots.yml
File metadata and controls
168 lines (147 loc) · 6.31 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
157
158
159
160
161
162
163
164
165
166
167
168
name: Snapshot Build and Pre-Release
on:
push:
branches: ["main"]
permissions:
contents: write
jobs:
test:
name: Run Tests
uses: ./.github/workflows/run-tests.yml
secrets: inherit
version-from-git:
name: Version from git
needs: test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate version
id: version
shell: bash
run: |
GIT_VERSION=$(git describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --always || echo "")
if [[ ! $GIT_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
COMMIT_COUNT=$(git rev-list --count HEAD)
GIT_VERSION="v0.0.0-dev.${COMMIT_COUNT}.${GITHUB_SHA:0:7}"
else
GIT_VERSION=$(echo "$GIT_VERSION" | sed -E 's/^v//; s/-([0-9]+)-g([a-f0-9]+)$/-dev.\1.\2/')
fi
GIT_VERSION=${GIT_VERSION#v}
echo "version=$GIT_VERSION" >> $GITHUB_OUTPUT
echo "Version: $GIT_VERSION"
build-and-pack:
name: Build and Pack NuGet Packages
needs: version-from-git
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
- name: Pack Eftdb
run: |
dotnet pack src/Eftdb/Eftdb.csproj -c Release --no-build -o ./packages /p:PackageVersion=${{ needs.version-from-git.outputs.version }}
- name: Pack Eftdb.Design
run: |
dotnet pack src/Eftdb.Design/Eftdb.Design.csproj -c Release --no-build -o ./packages /p:PackageVersion=${{ needs.version-from-git.outputs.version }}
- name: Upload NuGet packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages-snapshot
path: ./packages/*.nupkg
generate-changelog:
name: Generate Changelog
runs-on: ubuntu-latest
needs: build-and-pack
outputs:
changelog: ${{ steps.generate.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate Changelog
id: generate
shell: bash
run: |
chmod +x .github/scripts/generate-changelog.sh
OUTFILE=changelog_output.md
.github/scripts/generate-changelog.sh "$OUTFILE"
echo "changelog<<CHANGELOG_EOF" >> $GITHUB_OUTPUT
cat "$OUTFILE" >> $GITHUB_OUTPUT
echo "CHANGELOG_EOF" >> $GITHUB_OUTPUT
create-pre-release:
name: Create Pre-Release
needs: [version-from-git, build-and-pack, generate-changelog]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Organize artifacts
shell: bash
run: |
set -euo pipefail
mkdir -p release_files
for dir in artifacts/*; do
if [ -d "$dir" ]; then
echo "Processing artifact: $(basename "$dir")"
for file in "$dir"/*; do
if [ -f "$file" ]; then
cp "$file" "release_files/$(basename "$file")"
fi
done
fi
done
ls -la release_files/
- name: Extract build info
id: build_info
shell: bash
run: |
echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
echo "time=$(date +'%H%M')" >> $GITHUB_OUTPUT
echo "sha=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
GIT_VERSION=$(git describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --always || echo "")
if [[ ! $GIT_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
COMMIT_COUNT=$(git rev-list --count HEAD)
GIT_VERSION="v0.0.0-${COMMIT_COUNT}-${GITHUB_SHA:0:7}"
fi
echo "version=$GIT_VERSION" >> $GITHUB_OUTPUT
echo "Version from git: $GIT_VERSION"
- name: Update Dev Snapshot Release
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: dev-snapshot
name: "Dev Build ${{ steps.build_info.outputs.version }}"
prerelease: true
body: |
## Automated dev-snapshot
Version: ${{ steps.build_info.outputs.version }}
Date: ${{ steps.build_info.outputs.date }} ${{ steps.build_info.outputs.time }}
Commit: [${{ steps.build_info.outputs.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
> ⚠️ These are the latest development builds and may contain bugs or unfinished features.
### Changes
${{ needs.generate-changelog.outputs.changelog }}
files: |
./release_files/*