discharger 0.2.13 → 0.2.15
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 +4 -4
- data/CHANGELOG.md +2 -17
- data/README.md +203 -11
- data/lib/discharger/setup_runner/commands/database_command.rb +1 -1
- data/lib/discharger/setup_runner/commands/yarn_command.rb +21 -1
- data/lib/discharger/task.rb +14 -6
- data/lib/discharger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e92527599720c4eb9681913763e0d84c8c151b2cf93d96ec5dd5e8b6c3bc055
|
|
4
|
+
data.tar.gz: 7cc5f4c226faa5350703ba968bbe04df75aae75a087ca9cc9975bfbd30dd2eb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29e053cf5b57921975d1db1f0d063480b4df0b9b663dc21500f82ba7606760bd80df41eb293fc5831a037749a5453395550b4d4c7ef60b43f40327c18a8a7abe
|
|
7
|
+
data.tar.gz: 17802e2018819e350101312d5bee195eb8dae88ce2e19b5845ebf060d10bab3a0028fcee105b6ba88677671a75f37e92bca8d769f7039a8e16615e210735e576
|
data/CHANGELOG.md
CHANGED
|
@@ -5,23 +5,8 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
|
8
|
-
## [0.2.
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Added clean up fragment_directory task on Task.
|
|
13
|
-
- Added trusted publisher flow to GitHub release action.
|
|
14
|
-
- Adding commit step if needed after the finalize.
|
|
8
|
+
## [0.2.15] - 2025-10-24
|
|
15
9
|
|
|
16
10
|
### Fixed
|
|
17
11
|
|
|
18
|
-
-
|
|
19
|
-
- Added debugging for OIDC.
|
|
20
|
-
- Switching back to version 1.0.0 for trusted publisher
|
|
21
|
-
- Now going for the official RubyGems GitHub action for the gem publishing.
|
|
22
|
-
|
|
23
|
-
## [0.2.12] - 2025-08-19
|
|
24
|
-
|
|
25
|
-
### Added
|
|
26
|
-
|
|
27
|
-
- Added fragment directory attribute for task configuration.
|
|
12
|
+
- Respect packageManager version from package.json instead of forcing yarn@stable
|
data/README.md
CHANGED
|
@@ -46,22 +46,39 @@ Discharger::Task.create do |task|
|
|
|
46
46
|
task.pull_request_url = "https://github.com/SOFware/some-app"
|
|
47
47
|
|
|
48
48
|
# Changelog management (optional)
|
|
49
|
-
task.
|
|
49
|
+
task.fragment = "changelog.d" # Directory for changelog fragments
|
|
50
50
|
end
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
### Changelog
|
|
53
|
+
### Changelog Management
|
|
54
54
|
|
|
55
|
-
Discharger supports changelog
|
|
55
|
+
Discharger supports changelog management through the `fragment` setting from [Reissue](https://github.com/SOFware/reissue?tab=readme-ov-file#configuration-options).
|
|
56
|
+
|
|
57
|
+
#### Git Commit Trailers
|
|
58
|
+
|
|
59
|
+
Document changes directly in your commit messages using git trailers. Set `task.fragment = :git` to enable this feature:
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
Discharger::Task.create do |task|
|
|
63
|
+
# ... other configuration ...
|
|
64
|
+
task.fragment = :git # Enable git commit trailers
|
|
65
|
+
end
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This keeps changelog data coupled with your code changes in the same commit. See [Git Trailers Guide](docs/git-trailers-guide.md) for detailed usage instructions.
|
|
69
|
+
|
|
70
|
+
#### File-Based Fragments
|
|
71
|
+
|
|
72
|
+
Alternatively, you can use file-based fragments by creating individual changelog files in a directory:
|
|
56
73
|
|
|
57
74
|
```ruby
|
|
58
75
|
Discharger::Task.create do |task|
|
|
59
76
|
# ... other configuration ...
|
|
60
|
-
task.
|
|
77
|
+
task.fragment = "changelog.d" # Enable file-based fragments
|
|
61
78
|
end
|
|
62
79
|
```
|
|
63
80
|
|
|
64
|
-
With
|
|
81
|
+
With this approach, create individual changelog files in the `changelog.d/` directory:
|
|
65
82
|
|
|
66
83
|
```
|
|
67
84
|
changelog.d/
|
|
@@ -92,19 +109,194 @@ rake release:stage # ---------- STEP 2 ----------
|
|
|
92
109
|
2. **Stage** (`rake release:stage`): Update the staging branch and create a PR to production
|
|
93
110
|
3. **Release** (`rake release`): Release the current version to production by tagging and pushing to the production branch
|
|
94
111
|
|
|
112
|
+
### Building with a Working Branch
|
|
113
|
+
|
|
114
|
+
To release a specific working branch to stage instead of the default branch, use the `DISCHARGER_BUILD_BRANCH` environment variable:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
DISCHARGER_BUILD_BRANCH=your-feature-branch rake build
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
This will deploy your working branch to the staging environment.
|
|
121
|
+
|
|
122
|
+
#### Configuring Branch Names
|
|
123
|
+
|
|
124
|
+
You can configure the branch names in your Rakefile when setting up the discharger task:
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
require "discharger"
|
|
128
|
+
|
|
129
|
+
Discharger::Task.new do |task|
|
|
130
|
+
task.app_name = "MyApp"
|
|
131
|
+
task.working_branch = ENV.fetch("WORKING_BRANCH", "develop")
|
|
132
|
+
task.staging_branch = ENV.fetch("STAGING_BRANCH", "stage")
|
|
133
|
+
task.production_branch = ENV.fetch("PRODUCTION_BRANCH", "main")
|
|
134
|
+
# ... other configuration
|
|
135
|
+
end
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
This allows you to use environment variables to override the default branch names, or set project-specific defaults. The `DISCHARGER_BUILD_BRANCH` environment variable (shown above) provides a runtime override specifically for the build task.
|
|
139
|
+
|
|
140
|
+
## Development Setup Automation
|
|
141
|
+
|
|
142
|
+
Discharger includes a setup script that automates your development environment configuration. When you run the install generator, it creates a `bin/setup` script and a `config/setup.yml` configuration file.
|
|
143
|
+
|
|
144
|
+
### Running Setup
|
|
145
|
+
|
|
146
|
+
After installing Discharger, run the setup script to configure your development environment:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
$ bin/setup
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
This script is idempotent - you can run it multiple times safely, and it will ensure your environment is properly configured.
|
|
153
|
+
|
|
154
|
+
### Configuration
|
|
155
|
+
|
|
156
|
+
The setup process is configured through `config/setup.yml`. Here's an example configuration:
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
app_name: "YourAppName"
|
|
160
|
+
|
|
161
|
+
database:
|
|
162
|
+
port: 5432
|
|
163
|
+
name: "db-your-app"
|
|
164
|
+
version: "14"
|
|
165
|
+
password: "postgres"
|
|
166
|
+
|
|
167
|
+
redis:
|
|
168
|
+
port: 6379
|
|
169
|
+
name: "redis-your-app"
|
|
170
|
+
version: "latest"
|
|
171
|
+
|
|
172
|
+
# Built-in commands to run
|
|
173
|
+
steps:
|
|
174
|
+
- brew
|
|
175
|
+
- asdf
|
|
176
|
+
- git
|
|
177
|
+
- bundler
|
|
178
|
+
- yarn
|
|
179
|
+
- config
|
|
180
|
+
- docker
|
|
181
|
+
- env
|
|
182
|
+
- database
|
|
183
|
+
|
|
184
|
+
# Custom commands for your application
|
|
185
|
+
custom_steps:
|
|
186
|
+
- description: "Seed application data"
|
|
187
|
+
command: "bin/rails db:seed"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Using Default Steps
|
|
191
|
+
|
|
192
|
+
The `steps` array specifies which built-in setup commands to run. Available commands include:
|
|
193
|
+
|
|
194
|
+
- `brew` - Install Homebrew dependencies
|
|
195
|
+
- `asdf` - Setup version management with asdf
|
|
196
|
+
- `git` - Configure git settings
|
|
197
|
+
- `bundler` - Install Ruby gems
|
|
198
|
+
- `yarn` - Install JavaScript packages
|
|
199
|
+
- `config` - Copy configuration files
|
|
200
|
+
- `docker` - Setup Docker containers
|
|
201
|
+
- `env` - Configure environment variables
|
|
202
|
+
- `database` - Setup and migrate database
|
|
203
|
+
|
|
204
|
+
### Selecting Specific Steps
|
|
205
|
+
|
|
206
|
+
You can customize which steps run by modifying the `steps` array:
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
# Only run specific setup steps
|
|
210
|
+
steps:
|
|
211
|
+
- bundler
|
|
212
|
+
- database
|
|
213
|
+
- yarn
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Leave the array empty or omit it entirely to run all available steps.
|
|
217
|
+
|
|
218
|
+
### Adding Custom Commands
|
|
219
|
+
|
|
220
|
+
Add application-specific setup tasks using the `custom_steps` section:
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
custom_steps:
|
|
224
|
+
# Simple command
|
|
225
|
+
- description: "Compile assets"
|
|
226
|
+
command: "bin/rails assets:precompile"
|
|
227
|
+
|
|
228
|
+
# Command with condition
|
|
229
|
+
- description: "Setup Elasticsearch"
|
|
230
|
+
command: "bin/rails search:setup"
|
|
231
|
+
condition: "defined?(Elasticsearch)"
|
|
232
|
+
|
|
233
|
+
# Command with environment variable condition
|
|
234
|
+
- description: "Import production data"
|
|
235
|
+
command: "bin/rails db:import"
|
|
236
|
+
condition: "ENV['IMPORT_DATA'] == 'true'"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Each custom step can include:
|
|
240
|
+
- `description` - A description shown during setup
|
|
241
|
+
- `command` - The command to execute
|
|
242
|
+
- `condition` - An optional Ruby expression that must evaluate to true for the command to run
|
|
243
|
+
|
|
244
|
+
### Creating Custom Command Classes
|
|
245
|
+
|
|
246
|
+
For more complex setup logic, you can create custom command classes that integrate with Discharger's setup system:
|
|
247
|
+
|
|
248
|
+
```ruby
|
|
249
|
+
# lib/setup_commands/elasticsearch_command.rb
|
|
250
|
+
class ElasticsearchCommand < Discharger::SetupRunner::Commands::BaseCommand
|
|
251
|
+
def description
|
|
252
|
+
"Configure Elasticsearch"
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def can_execute?
|
|
256
|
+
defined?(Elasticsearch)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def execute
|
|
260
|
+
with_spinner("Setting up Elasticsearch...") do
|
|
261
|
+
# Your setup logic here
|
|
262
|
+
system("bin/rails search:setup")
|
|
263
|
+
system("bin/rails search:reindex")
|
|
264
|
+
end
|
|
265
|
+
log "Elasticsearch configured successfully", emoji: "✅"
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# Register the command in an initializer or your setup script
|
|
270
|
+
Discharger::SetupRunner.register_command(:elasticsearch, ElasticsearchCommand)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Then use it in your configuration:
|
|
274
|
+
|
|
275
|
+
```yaml
|
|
276
|
+
steps:
|
|
277
|
+
- bundler
|
|
278
|
+
- database
|
|
279
|
+
- elasticsearch # Your custom command
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
|
|
95
283
|
## Contributing
|
|
96
284
|
|
|
97
285
|
This gem is managed with [Reissue](https://github.com/SOFware/reissue).
|
|
98
286
|
|
|
99
287
|
### Releasing
|
|
100
288
|
|
|
101
|
-
Releases are
|
|
289
|
+
Releases are streamlined with a single GitHub Actions workflow using RubyGems Trusted Publishing:
|
|
102
290
|
|
|
103
|
-
1. Go to Actions → "
|
|
104
|
-
2. Select version type (
|
|
105
|
-
3.
|
|
106
|
-
|
|
107
|
-
|
|
291
|
+
1. Go to Actions → "Release gem to RubyGems.org" → Run workflow
|
|
292
|
+
2. Select version bump type (patch, minor, or major)
|
|
293
|
+
3. The workflow will automatically:
|
|
294
|
+
- Finalize the changelog with the release date
|
|
295
|
+
- Build the gem with checksum verification
|
|
296
|
+
- Publish to RubyGems.org via Trusted Publishing (no API keys needed)
|
|
297
|
+
- Create a git tag for the release
|
|
298
|
+
- Bump to the next development version
|
|
299
|
+
- Open a PR with the version bump for continued development
|
|
108
300
|
|
|
109
301
|
Bug reports and pull requests are welcome on GitHub.
|
|
110
302
|
|
|
@@ -93,7 +93,7 @@ module Discharger
|
|
|
93
93
|
end
|
|
94
94
|
RUBY
|
|
95
95
|
|
|
96
|
-
with_spinner("Terminating existing database connections#{
|
|
96
|
+
with_spinner("Terminating existing database connections#{" (#{rails_env})" if rails_env}") do
|
|
97
97
|
stdout, stderr, status = Open3.capture3(env_vars, "bin/rails", "runner", runner_script)
|
|
98
98
|
|
|
99
99
|
if status.success?
|
|
@@ -13,7 +13,27 @@ module Discharger
|
|
|
13
13
|
if File.exist?(File.join(app_root, "yarn.lock"))
|
|
14
14
|
if system_quiet("which corepack")
|
|
15
15
|
system! "corepack enable"
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
package_json_path = File.join(app_root, "package.json")
|
|
18
|
+
if File.exist?(package_json_path)
|
|
19
|
+
begin
|
|
20
|
+
require "json"
|
|
21
|
+
package_json = JSON.parse(File.read(package_json_path))
|
|
22
|
+
|
|
23
|
+
if package_json["packageManager"]&.start_with?("yarn@")
|
|
24
|
+
yarn_spec = package_json["packageManager"].split("+").first
|
|
25
|
+
log "Using #{yarn_spec} from package.json"
|
|
26
|
+
system! "corepack use #{yarn_spec}"
|
|
27
|
+
else
|
|
28
|
+
system! "corepack use yarn@stable"
|
|
29
|
+
end
|
|
30
|
+
rescue JSON::ParserError => e
|
|
31
|
+
log "Warning: Could not parse package.json: #{e.message}"
|
|
32
|
+
system! "corepack use yarn@stable"
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
system! "corepack use yarn@stable"
|
|
36
|
+
end
|
|
17
37
|
end
|
|
18
38
|
|
|
19
39
|
# Install dependencies
|
data/lib/discharger/task.rb
CHANGED
|
@@ -16,7 +16,11 @@ module Discharger
|
|
|
16
16
|
reissue.updated_paths = task.updated_paths
|
|
17
17
|
reissue.commit = task.commit
|
|
18
18
|
reissue.commit_finalize = task.commit_finalize
|
|
19
|
-
|
|
19
|
+
if task.fragment_directory
|
|
20
|
+
warn "fragment_directory is deprecated, use fragment instead"
|
|
21
|
+
task.fragment = task.fragment_directory
|
|
22
|
+
end
|
|
23
|
+
reissue.fragment = task.fragment
|
|
20
24
|
reissue.clear_fragments = task.clear_fragments
|
|
21
25
|
end
|
|
22
26
|
task.define
|
|
@@ -39,6 +43,7 @@ module Discharger
|
|
|
39
43
|
attr_accessor :commit_identifier
|
|
40
44
|
attr_accessor :pull_request_url
|
|
41
45
|
attr_accessor :fragment_directory
|
|
46
|
+
attr_accessor :fragment
|
|
42
47
|
attr_accessor :clear_fragments
|
|
43
48
|
|
|
44
49
|
attr_reader :last_message_ts
|
|
@@ -46,7 +51,7 @@ module Discharger
|
|
|
46
51
|
# Reissue settings
|
|
47
52
|
attr_accessor(
|
|
48
53
|
*Reissue::Task.instance_methods(false).reject { |method|
|
|
49
|
-
method.to_s.match?(/[
|
|
54
|
+
method.to_s.match?(/[?=]\z/) || method_defined?(method)
|
|
50
55
|
}
|
|
51
56
|
)
|
|
52
57
|
|
|
@@ -204,17 +209,20 @@ module Discharger
|
|
|
204
209
|
|
|
205
210
|
desc description
|
|
206
211
|
task build: :environment do
|
|
212
|
+
# Allow overriding the working branch via environment variable
|
|
213
|
+
build_branch = ENV["DISCHARGER_BUILD_BRANCH"] || working_branch
|
|
214
|
+
|
|
207
215
|
syscall(
|
|
208
|
-
["git fetch origin #{
|
|
209
|
-
["git checkout #{
|
|
210
|
-
["git reset --hard origin/#{
|
|
216
|
+
["git fetch origin #{build_branch}"],
|
|
217
|
+
["git checkout #{build_branch}"],
|
|
218
|
+
["git reset --hard origin/#{build_branch}"],
|
|
211
219
|
["git branch -D #{staging_branch} 2>/dev/null || true"],
|
|
212
220
|
["git checkout -b #{staging_branch}"],
|
|
213
221
|
["git push origin #{staging_branch} --force"]
|
|
214
222
|
) do
|
|
215
223
|
current_version = Object.const_get(version_constant)
|
|
216
224
|
tasker["#{name}:slack"].invoke("Building #{app_name} #{current_version} (#{commit_identifier.call}) on #{staging_branch}.", release_message_channel)
|
|
217
|
-
syscall ["git checkout #{
|
|
225
|
+
syscall ["git checkout #{build_branch}"]
|
|
218
226
|
end
|
|
219
227
|
end
|
|
220
228
|
|
data/lib/discharger/version.rb
CHANGED