-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 3.26 KB
/
mime-sync.yml
File metadata and controls
90 lines (75 loc) · 3.26 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
name: MIME database sync
on:
schedule:
- cron: '0 3 * * 1'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
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: Run MIME sync tool
run: >
dotnet run --project ManagedCode.MimeTypes.Sync --configuration Release --
--template-concurrency 8
- name: Detect MIME database changes
id: mime_changes
shell: bash
run: |
if git diff --quiet -- ManagedCode.MimeTypes/mimeTypes.json ManagedCode.MimeTypes/mimeTypes.metadata.json; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No MIME database changes detected." >> "$GITHUB_STEP_SUMMARY"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "MIME database changes detected." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Bump patch package version
if: steps.mime_changes.outputs.changed == 'true'
shell: bash
run: |
set -euo pipefail
current_version="$(sed -nE 's#.*<Version>([^<]+)</Version>.*#\1#p' Directory.Build.props | head -n 1)"
package_version="$(sed -nE 's#.*<PackageVersion>([^<]+)</PackageVersion>.*#\1#p' Directory.Build.props | head -n 1)"
if [[ "$current_version" != "$package_version" ]]; then
echo "Version and PackageVersion differ: $current_version vs $package_version" >&2
exit 1
fi
if [[ ! "$current_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Unsupported version format: $current_version" >&2
exit 1
fi
IFS='.' read -r major minor patch <<< "$current_version"
next_version="$major.$minor.$((patch + 1))"
perl -0pi -e "s#<Version>\\Q$current_version\\E</Version>#<Version>$next_version</Version>#; s#<PackageVersion>\\Q$current_version\\E</PackageVersion>#<PackageVersion>$next_version</PackageVersion>#;" Directory.Build.props
echo "Bumped package version: $current_version -> $next_version" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Test synced database
run: dotnet test --configuration Release --no-restore --verbosity normal
- name: Create Pull Request
if: steps.mime_changes.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: sync MIME database"
title: "chore: sync MIME database"
body: |
Automated update of the MIME database from the IANA media types registry,
Apache mime.types, mime-db gap-fill entries, and curated ManagedCode overrides.
When MIME data changes, this PR also bumps the package patch version.
See the workflow summary for the IANA registry date, source counts, and version bump.
branch: chore/sync-mime-database
delete-branch: true
labels: |
automation
dependencies