-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from vamsii777/feat/improve-timezone-handling
Restructure & Improve TZDB Processing
- Loading branch information
Showing
20 changed files
with
2,615 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
name: Create Release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create-release: | ||
name: Create Release | ||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Determine Next Version | ||
id: version | ||
run: | | ||
# Get latest release tag (if any) | ||
latest_tag=$(gh release view --json tagName --jq .tagName || echo "v0.0.0") | ||
# Extract major, minor, patch numbers | ||
if [[ $latest_tag =~ v([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | ||
major="${BASH_REMATCH[1]}" | ||
minor="${BASH_REMATCH[2]}" | ||
patch="${BASH_REMATCH[3]}" | ||
else | ||
major=0 | ||
minor=0 | ||
patch=0 | ||
fi | ||
# Determine version bump type from PR labels | ||
if contains(github.event.pull_request.labels.*.name, 'major'); then | ||
major=$((major + 1)) | ||
minor=0 | ||
patch=0 | ||
elif contains(github.event.pull_request.labels.*.name, 'minor'); then | ||
minor=$((minor + 1)) | ||
patch=0 | ||
else | ||
# Default to patch bump if no major/minor label | ||
patch=$((patch + 1)) | ||
fi | ||
new_version="v${major}.${minor}.${patch}" | ||
echo "New version will be: $new_version" | ||
echo "version=$new_version" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Generate Release Notes | ||
id: release-notes | ||
run: | | ||
# Get PR description | ||
DESCRIPTION="${{ github.event.pull_request.body }}" | ||
# Get list of changes since last release | ||
CHANGES=$(gh pr list \ | ||
--base main \ | ||
--state merged \ | ||
--json title,number,mergedAt,labels \ | ||
--search "merged:>=$(gh release view --json publishedAt --jq .publishedAt || echo "v0.0.0")") | ||
# Extract PR description and format it | ||
DESCRIPTION=$(echo "$DESCRIPTION" | sed '/<!--.*-->/d') | ||
# Format the release notes | ||
NOTES="## What's Changed | ||
${DESCRIPTION} | ||
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} | ||
## Installation | ||
Add to your \`Package.swift\`: | ||
\`\`\`swift | ||
dependencies: [ | ||
.package(url: \"https://github.com/vamsii777/SwiftTZ.git\", from: \"${{ steps.version.outputs.version }}\") | ||
] | ||
\`\`\` | ||
" | ||
# Save to file (handles multiline better than environment variables) | ||
echo "$NOTES" > release_notes.md | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ steps.version.outputs.version }} | ||
name: Release ${{ steps.version.outputs.version }} | ||
body_path: release_notes.md | ||
draft: false | ||
prerelease: false | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update Documentation | ||
if: success() | ||
run: | | ||
# Add any documentation update steps here | ||
echo "Documentation updated for version ${{ steps.version.outputs.version }}" | ||
- name: Notify on Failure | ||
if: failure() | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '❌ Failed to create release. Please check the workflow logs for details.' | ||
}) | ||
- name: Update README.md Version | ||
if: success() | ||
run: | | ||
VERSION="${{ steps.version.outputs.version }}" | ||
VERSION_NO_V="${VERSION#v}" # Remove 'v' prefix | ||
# Update version in README.md | ||
sed -i.bak 's/\.package(url: "https:\/\/github\.com\/vamsii777\/SwiftTZ\.git", from: "[0-9]*\.[0-9]*\.[0-9]*")/\.package(url: "https:\/\/github\.com\/vamsii777\/SwiftTZ\.git", from: "'$VERSION_NO_V'")/' README.md | ||
rm README.md.bak | ||
- name: Commit Version Updates | ||
if: success() | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add Package.swift README.md | ||
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,39 @@ | ||
import CompilerPluginSupport | ||
// swift-tools-version: 6.0 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SwiftTZ", | ||
platforms: [ | ||
.macOS(.v13), | ||
.iOS(.v16), | ||
.watchOS(.v9), | ||
.tvOS(.v16), | ||
.macCatalyst(.v16), | ||
.visionOS(.v1), | ||
], | ||
products: [ | ||
.library(name: "SwiftTZ", targets: ["SwiftTZ"]), | ||
.executable(name: "tzdb-gen", targets: ["SwiftTZGenerator"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/apple/pkl-swift.git", from: "0.3.0") | ||
], | ||
targets: [ | ||
// Generator executable | ||
.executableTarget( | ||
name: "SwiftTZGenerator", | ||
dependencies: [ | ||
.product(name: "PklSwift", package: "pkl-swift") | ||
] | ||
), | ||
|
||
// Main library | ||
.target( | ||
name: "SwiftTZ", | ||
dependencies: [ | ||
.product(name: "PklSwift", package: "pkl-swift") | ||
] | ||
), | ||
|
||
// Tests | ||
.testTarget( | ||
name: "SwiftTZTests", | ||
dependencies: [ | ||
"SwiftTZ" | ||
] | ||
), | ||
] | ||
name: "swifttz", | ||
platforms: [ | ||
.macOS(.v13), | ||
.iOS(.v16), | ||
.watchOS(.v9), | ||
.tvOS(.v16), | ||
.macCatalyst(.v16), | ||
.visionOS(.v1) | ||
], | ||
products: [ | ||
.library(name: "SwiftTZ", targets: ["SwiftTZ"]), | ||
.executable(name: "tzdb-gen", targets: ["SwiftTZGenerator"]), | ||
], | ||
targets: [ | ||
// Generator executable | ||
.executableTarget( | ||
name: "SwiftTZGenerator", | ||
dependencies: [] | ||
), | ||
|
||
// Main library | ||
.target( | ||
name: "SwiftTZ", | ||
dependencies: [] | ||
), | ||
|
||
// Tests | ||
.testTarget( | ||
name: "SwiftTZTests", | ||
dependencies: [ | ||
"SwiftTZ" | ||
] | ||
), | ||
] | ||
) |
Oops, something went wrong.