Skip to content

Commit 0b499e6

Browse files
committed
ci: add release workflow, remove version bump from data updates
1 parent 8722ecb commit 0b499e6

2 files changed

Lines changed: 69 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
release:
10+
name: Bump Version & Update Changelog
11+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'data-update')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Bump patch version
32+
id: bump
33+
run: |
34+
OLD_VERSION=$(node -p "require('./package.json').version")
35+
NEW_VERSION=$(npm version patch --no-git-tag-version)
36+
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
37+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
38+
echo "Bumped $OLD_VERSION -> $NEW_VERSION"
39+
40+
- name: Update CHANGELOG.md
41+
env:
42+
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
43+
PR_NUMBER: ${{ github.event.pull_request.number }}
44+
run: |
45+
DATE=$(date +%Y-%m-%d)
46+
ENTRY="## [${NEW_VERSION#v}] - $DATE\n\n### Changed\n- Updated timezone data from upstream database (PR #$PR_NUMBER)\n"
47+
48+
if [ -f CHANGELOG.md ]; then
49+
# Insert after the first line (# Changelog header)
50+
sed -i "0,/^## \[/s//$ENTRY\n## [/" CHANGELOG.md
51+
else
52+
printf "# Changelog\n\nAll notable changes to \`@countrystatecity/timezones\` will be documented in this file.\n\n$ENTRY" > CHANGELOG.md
53+
fi
54+
55+
- name: Build and test
56+
run: |
57+
npm run build
58+
npm test
59+
60+
- name: Commit and push
61+
env:
62+
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
63+
run: |
64+
git config user.name "github-actions[bot]"
65+
git config user.email "github-actions[bot]@users.noreply.github.com"
66+
git add package.json package-lock.json CHANGELOG.md
67+
git commit -m "chore: release ${NEW_VERSION}"
68+
git push

.github/workflows/update-data.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,13 @@ jobs:
9090
echo "No data changes detected"
9191
fi
9292
93-
- name: Bump patch version
94-
if: steps.check-changes.outputs.changed == 'true'
95-
id: bump-version
96-
run: |
97-
NEW_VERSION=$(npm version patch --no-git-tag-version)
98-
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
99-
echo "Bumped version to $NEW_VERSION"
100-
10193
- name: Create Pull Request
10294
if: steps.check-changes.outputs.changed == 'true'
10395
uses: peter-evans/create-pull-request@v6
10496
with:
10597
token: ${{ secrets.GITHUB_TOKEN }}
10698
commit-message: 'chore: update timezone data'
107-
title: '🔄 Automated Timezone Data Update ${{ steps.bump-version.outputs.version }}'
99+
title: '🔄 Automated Timezone Data Update'
108100
body: |
109101
## Automated Timezone Data Update
110102

0 commit comments

Comments
 (0)