englishnepalidateconverter 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5b1bc863beae761d07b77b3e4ff5081c642e7e1aef2dd326bd646de58adaa4f
4
- data.tar.gz: b9b0641bcb2a06604d94128efca2ccccd70d11cda5902efc69c155d97c73c306
3
+ metadata.gz: 9245fe63ba23fc4112152bf3eb0950b314c8427dae211ea38fe1001108d4909c
4
+ data.tar.gz: 6327d4c9ec48085893eb2b91f9c1fe226268398d49a4eb927566f31558680afd
5
5
  SHA512:
6
- metadata.gz: cce984e5a63bb15a2268318ab01eeb5de0f29dc6baad7b3097cb3391ee1b38efb4006e008e0a0b06967b96562e3477d2ea2d225d0bd236c567fd0883d9e5cf06
7
- data.tar.gz: 5b6eed8c2afc6099fdcb6bfd4e0fa062bf0f29061d832506d1cd7bc8f8fc3e6705b75d2977198a931beb11364e174005532a12595fcb09a3e96e649c315fc55b
6
+ metadata.gz: 23a1b2025afb02c50987b6f78d05e76b9b87e31bb291cfd9a7fdd25c2a5c65a880c7e78441eb0a40e9ae398ecae10840ebf8f43bc45ccd4f973bd312a0b83adc
7
+ data.tar.gz: 49e2e0b7a6bef9fae4d949f79ca172773becd2fb916ad31d7e9958745c770a11192522b46bb82048c4465ceead5d02cd6e202feeadd80abbe2254e0876331209
@@ -0,0 +1,89 @@
1
+ name: Bump version
2
+
3
+ # Run from GitHub: Actions → "Bump version" → Run workflow, then pick patch, minor or major.
4
+ # It updates lib/englishnepalidateconverter/version.rb, commits it to master, and starts
5
+ # CI on master. CI sees a version with no tag yet, publishes the gem and tags vX.Y.Z.
6
+ on:
7
+ workflow_dispatch:
8
+ inputs:
9
+ bump:
10
+ description: "Which part of the version to bump"
11
+ required: true
12
+ default: patch
13
+ type: choice
14
+ options:
15
+ - patch
16
+ - minor
17
+ - major
18
+
19
+ permissions:
20
+ contents: write # push the version commit
21
+ actions: write # start the CI workflow
22
+
23
+ concurrency:
24
+ group: bump-version
25
+ cancel-in-progress: false
26
+
27
+ jobs:
28
+ bump:
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ with:
33
+ ref: master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: .ruby-version
38
+ bundler-cache: true
39
+
40
+ - name: Run tests before bumping
41
+ run: |
42
+ bundle exec rspec
43
+ bundle exec rubocop
44
+
45
+ - name: Bump version.rb
46
+ id: bump
47
+ env:
48
+ BUMP: ${{ inputs.bump }}
49
+ run: |
50
+ file=lib/englishnepalidateconverter/version.rb
51
+ new_version=$(ruby -e '
52
+ file, bump = ARGV
53
+ source = File.read(file)
54
+ match = source.match(/VERSION = "(\d+)\.(\d+)\.(\d+)"/) or abort("No VERSION found in #{file}")
55
+ major, minor, patch = match.captures.map(&:to_i)
56
+ case bump
57
+ when "major" then major += 1; minor = 0; patch = 0
58
+ when "minor" then minor += 1; patch = 0
59
+ when "patch" then patch += 1
60
+ else abort("Unknown bump: #{bump}")
61
+ end
62
+ version = "#{major}.#{minor}.#{patch}"
63
+ File.write(file, source.sub(match[0], %(VERSION = "#{version}")))
64
+ puts version
65
+ ' "$file" "$BUMP")
66
+ if git rev-parse -q --verify "refs/tags/v$new_version" >/dev/null || \
67
+ git ls-remote --exit-code --tags origin "refs/tags/v$new_version" >/dev/null; then
68
+ echo "Tag v$new_version already exists"
69
+ exit 1
70
+ fi
71
+ echo "version=$new_version" >> "$GITHUB_OUTPUT"
72
+ git diff
73
+
74
+ - name: Commit and push
75
+ env:
76
+ VERSION: ${{ steps.bump.outputs.version }}
77
+ run: |
78
+ git config user.name "github-actions[bot]"
79
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
80
+ git add lib/englishnepalidateconverter/version.rb
81
+ git commit -m "Bump version to $VERSION"
82
+ git push origin master
83
+
84
+ # A push made with GITHUB_TOKEN does not trigger other workflows,
85
+ # so start CI on master explicitly; its release job publishes and tags.
86
+ - name: Start release
87
+ env:
88
+ GH_TOKEN: ${{ github.token }}
89
+ run: gh workflow run ci.yml --ref master
@@ -3,8 +3,10 @@ name: CI
3
3
  on:
4
4
  push:
5
5
  branches: [master]
6
- tags: ["v*"]
7
6
  pull_request:
7
+ # Run manually from the Actions tab to retry a release, e.g. if one of the
8
+ # two gems failed to publish. Gems already on RubyGems.org are skipped.
9
+ workflow_dispatch:
8
10
 
9
11
  permissions:
10
12
  contents: read
@@ -23,28 +25,47 @@ jobs:
23
25
  - name: Run linter
24
26
  run: bundle exec rubocop
25
27
 
26
- # Runs only when a version tag (e.g. v2.0.1) is pushed, after the tests pass.
27
- # Publishes the same gem under two names on RubyGems.org.
28
+ # Releases automatically when a commit on master has a version that has no
29
+ # git tag yet: builds the gem under both names, pushes both to RubyGems.org,
30
+ # then creates and pushes the vX.Y.Z tag. To release, just bump VERSION.
28
31
  release:
29
32
  needs: test
30
- if: startsWith(github.ref, 'refs/tags/v')
33
+ if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
31
34
  runs-on: ubuntu-latest
32
35
  permissions:
33
- contents: read
36
+ contents: write # needed to push the version tag
34
37
  id-token: write # needed for RubyGems.org trusted publishing
35
38
  steps:
36
39
  - uses: actions/checkout@v4
37
40
  - uses: ruby/setup-ruby@v1
38
41
  with:
39
42
  ruby-version: .ruby-version
40
- - name: Check tag matches gem version
43
+
44
+ - name: Read version and check for existing tag
45
+ id: version
41
46
  run: |
42
47
  version=$(ruby -Ilib -e 'require "englishnepalidateconverter/version"; puts EnglishNepaliDateConverter::VERSION')
43
- if [ "v$version" != "$GITHUB_REF_NAME" ]; then
44
- echo "Tag $GITHUB_REF_NAME does not match gem version $version"
45
- exit 1
48
+ echo "version=$version" >> "$GITHUB_OUTPUT"
49
+ if git ls-remote --exit-code --tags origin "refs/tags/v$version" > /dev/null; then
50
+ echo "tag_exists=true" >> "$GITHUB_OUTPUT"
51
+ echo "Tag v$version already exists"
52
+ else
53
+ echo "tag_exists=false" >> "$GITHUB_OUTPUT"
54
+ echo "Tag v$version does not exist yet, releasing"
46
55
  fi
56
+
57
+ - name: Decide whether to release
58
+ id: release
59
+ run: |
60
+ if [ "${{ steps.version.outputs.tag_exists }}" = "false" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
61
+ echo "publish=true" >> "$GITHUB_OUTPUT"
62
+ else
63
+ echo "publish=false" >> "$GITHUB_OUTPUT"
64
+ echo "Version unchanged, nothing to release"
65
+ fi
66
+
47
67
  - name: Build gems
68
+ if: steps.release.outputs.publish == 'true'
48
69
  run: |
49
70
  ruby -rrubygems/package -e '
50
71
  spec = Gem::Specification.load("englishnepalidateconverter.gemspec")
@@ -56,16 +77,27 @@ jobs:
56
77
  '
57
78
  ls -l *.gem
58
79
 
59
- - name: Configure RubyGems credentials (englishnepalidateconverter)
80
+ - name: Configure RubyGems credentials
81
+ if: steps.release.outputs.publish == 'true'
60
82
  uses: rubygems/configure-rubygems-credentials@v2.2.0
61
- - name: Push englishnepalidateconverter
62
- run: gem push englishnepalidateconverter-*.gem
63
83
 
64
- # The first release of a new gem through a pending trusted publisher needs
65
- # the RubyGems.org account ID. Set it as the repository variable RUBYGEMS_OWNER_ID.
66
- - name: Configure RubyGems credentials (english_nepali_date_converter)
67
- uses: rubygems/configure-rubygems-credentials@v2.2.0
68
- with:
69
- owner: ${{ vars.RUBYGEMS_OWNER_ID }}
70
- - name: Push english_nepali_date_converter
71
- run: gem push english_nepali_date_converter-*.gem
84
+ - name: Push gems to RubyGems.org
85
+ if: steps.release.outputs.publish == 'true'
86
+ run: |
87
+ for gem in *.gem; do
88
+ if output=$(gem push "$gem" 2>&1); then
89
+ echo "$output"
90
+ elif echo "$output" | grep -q "Repushing of gem versions is not allowed"; then
91
+ echo "$gem is already on RubyGems.org, skipping"
92
+ else
93
+ echo "$output"
94
+ exit 1
95
+ fi
96
+ done
97
+
98
+ - name: Create and push version tag
99
+ if: steps.release.outputs.publish == 'true' && steps.version.outputs.tag_exists == 'false'
100
+ run: |
101
+ tag="v${{ steps.version.outputs.version }}"
102
+ git tag "$tag"
103
+ git push origin "$tag"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EnglishNepaliDateConverter
4
- VERSION = "2.0.1"
4
+ VERSION = "2.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: englishnepalidateconverter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dlamichhane
@@ -114,6 +114,7 @@ executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
+ - ".github/workflows/bump-version.yml"
117
118
  - ".github/workflows/ci.yml"
118
119
  - ".gitignore"
119
120
  - ".rspec"