acro_that 0.1.1 → 0.1.3

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.
data/publish ADDED
@@ -0,0 +1,183 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any error
4
+
5
+ VERSION_FILE="lib/acro_that/version.rb"
6
+ GEMSPEC_FILE="acro_that.gemspec"
7
+ GEM_NAME="acro_that"
8
+
9
+ # Function to show usage
10
+ usage() {
11
+ cat << EOF
12
+ Usage: $0 [OPTIONS]
13
+
14
+ Publish acro_that gem to RubyGems.
15
+
16
+ OPTIONS:
17
+ -b, --bump TYPE Bump version before publishing (major|minor|patch)
18
+ -k, --key KEY RubyGems API key name (optional, uses credentials if not provided)
19
+ -h, --help Show this help message
20
+
21
+ EXAMPLES:
22
+ $0 # Publish current version without bumping
23
+ $0 -b patch # Bump patch version (0.1.2 -> 0.1.3)
24
+ $0 -b minor # Bump minor version (0.1.2 -> 0.2.0)
25
+ $0 -b major # Bump major version (0.1.2 -> 1.0.0)
26
+ $0 -b patch -k mykey # Bump patch and use specific API key
27
+
28
+ EOF
29
+ exit 1
30
+ }
31
+
32
+ # Function to get current version
33
+ get_current_version() {
34
+ if [[ ! -f "$VERSION_FILE" ]]; then
35
+ echo "Error: $VERSION_FILE not found!" >&2
36
+ exit 1
37
+ fi
38
+
39
+ # Extract version using awk (works reliably on both macOS and Linux)
40
+ awk -F'"' '/VERSION =/ {print $2}' "$VERSION_FILE"
41
+ }
42
+
43
+ # Function to bump version
44
+ bump_version() {
45
+ local bump_type=$1
46
+ local current_version=$(get_current_version)
47
+
48
+ IFS='.' read -ra VERSION_PARTS <<< "$current_version"
49
+ local major=${VERSION_PARTS[0]:-0}
50
+ local minor=${VERSION_PARTS[1]:-0}
51
+ local patch=${VERSION_PARTS[2]:-0}
52
+
53
+ case "$bump_type" in
54
+ major)
55
+ major=$((major + 1))
56
+ minor=0
57
+ patch=0
58
+ ;;
59
+ minor)
60
+ minor=$((minor + 1))
61
+ patch=0
62
+ ;;
63
+ patch)
64
+ patch=$((patch + 1))
65
+ ;;
66
+ *)
67
+ echo "Error: Invalid bump type: $bump_type" >&2
68
+ echo "Must be one of: major, minor, patch" >&2
69
+ exit 1
70
+ ;;
71
+ esac
72
+
73
+ local new_version="${major}.${minor}.${patch}"
74
+
75
+ # Update version in version.rb
76
+ if [[ "$OSTYPE" == "darwin"* ]]; then
77
+ # macOS uses BSD sed
78
+ sed -i '' "s/VERSION = \".*\"/VERSION = \"$new_version\"/" "$VERSION_FILE"
79
+ else
80
+ # Linux uses GNU sed
81
+ sed -i "s/VERSION = \".*\"/VERSION = \"$new_version\"/" "$VERSION_FILE"
82
+ fi
83
+
84
+ echo "$new_version"
85
+ }
86
+
87
+ # Parse arguments
88
+ BUMP_TYPE=""
89
+ API_KEY=""
90
+
91
+ while [[ $# -gt 0 ]]; do
92
+ case $1 in
93
+ -b|--bump)
94
+ BUMP_TYPE="$2"
95
+ shift 2
96
+ ;;
97
+ -k|--key)
98
+ API_KEY="$2"
99
+ shift 2
100
+ ;;
101
+ -h|--help)
102
+ usage
103
+ ;;
104
+ *)
105
+ echo "Error: Unknown option: $1" >&2
106
+ usage
107
+ ;;
108
+ esac
109
+ done
110
+
111
+ # Validate bump type if provided
112
+ if [[ -n "$BUMP_TYPE" ]]; then
113
+ if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
114
+ echo "Error: Invalid bump type: $BUMP_TYPE" >&2
115
+ echo "Must be one of: major, minor, patch" >&2
116
+ exit 1
117
+ fi
118
+ fi
119
+
120
+ # Get version (after potential bump)
121
+ if [[ -n "$BUMP_TYPE" ]]; then
122
+ echo "Bumping $BUMP_TYPE version..."
123
+ VERSION=$(bump_version "$BUMP_TYPE")
124
+ echo "New version: $VERSION"
125
+ else
126
+ VERSION=$(get_current_version)
127
+ echo "Using current version: $VERSION"
128
+ fi
129
+
130
+ # Build the gem
131
+ echo "Building gem..."
132
+ GEM_FILE="${GEM_NAME}-${VERSION}.gem"
133
+ gem build "$GEMSPEC_FILE"
134
+
135
+ if [[ ! -f "$GEM_FILE" ]]; then
136
+ echo "Error: Failed to build gem file: $GEM_FILE" >&2
137
+ exit 1
138
+ fi
139
+
140
+ echo "Gem built successfully: $GEM_FILE"
141
+
142
+ # Push to RubyGems
143
+ echo "Pushing to RubyGems..."
144
+ if [[ -n "$API_KEY" ]]; then
145
+ gem push "$GEM_FILE" --key "$API_KEY"
146
+ else
147
+ gem push "$GEM_FILE"
148
+ fi
149
+
150
+ if [[ $? -ne 0 ]]; then
151
+ echo "Error: Failed to push gem to RubyGems" >&2
152
+ exit 1
153
+ fi
154
+
155
+ echo "Gem pushed to RubyGems successfully"
156
+
157
+ # Commit and push to git (only if version was bumped or if there are changes)
158
+ if [[ -n "$BUMP_TYPE" ]] || ! git diff --quiet "$VERSION_FILE"; then
159
+ echo "Committing version change..."
160
+ git add "$VERSION_FILE"
161
+ git commit -m "v${VERSION}"
162
+
163
+ echo "Creating and pushing tag..."
164
+ git tag -a "v${VERSION}" -m "Release version ${VERSION}"
165
+
166
+ echo "Pushing to origin..."
167
+ git push origin main
168
+ git push origin "v${VERSION}"
169
+
170
+ echo "Git operations completed successfully"
171
+ else
172
+ echo "No version changes to commit"
173
+ fi
174
+
175
+ echo ""
176
+ echo "✅ Successfully published ${GEM_NAME} v${VERSION}!"
177
+ echo " - Gem built: ${GEM_FILE}"
178
+ echo " - Pushed to RubyGems"
179
+ if [[ -n "$BUMP_TYPE" ]]; then
180
+ echo " - Version bumped and committed"
181
+ echo " - Tagged as v${VERSION}"
182
+ fi
183
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acro_that
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Wynkoop
@@ -98,9 +98,12 @@ files:
98
98
  - Rakefile
99
99
  - acro_that.gemspec
100
100
  - docs/README.md
101
+ - docs/clear_fields.md
101
102
  - docs/dict_scan_explained.md
102
103
  - docs/object_streams.md
103
104
  - docs/pdf_structure.md
105
+ - issues/README.md
106
+ - issues/refactoring-opportunities.md
104
107
  - lib/acro_that.rb
105
108
  - lib/acro_that/actions/add_field.rb
106
109
  - lib/acro_that/actions/add_signature_appearance.rb
@@ -115,6 +118,7 @@ files:
115
118
  - lib/acro_that/objstm.rb
116
119
  - lib/acro_that/pdf_writer.rb
117
120
  - lib/acro_that/version.rb
121
+ - publish
118
122
  homepage: https://github.com/wynk182/acro_that
119
123
  licenses:
120
124
  - MIT