discharger 0.2.13 → 0.2.14
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 +16 -6
- data/README.md +184 -9
- data/lib/discharger/setup_runner/commands/database_command.rb +1 -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: 1318e95cac939c76337bcccee4a9abc6403c854abab6fd9caac9854690f8eb66
|
4
|
+
data.tar.gz: e55e2a6b87075e1a4a02d7ad9ffac6d5d84a4f11d3d7d7cebc14176f4ebd083f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9831c798d0e372384d783eafd50287913d99744d610bd93df67235a2ad7a916f0a2a5d31e8e6f44de961671092ee86630c970860ddbdc61d5fc77247ee170dc2
|
7
|
+
data.tar.gz: 5774f102c2bbd0c1eadd4cc6511fc80e719a73f98f90a0447ab4696829eb576a0d3d9ab28fb764e44d6b2fb9448f96ffe0142237a0dd79f64a278a30b93de4d1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,22 @@ 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.14] - 2025-09-23
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Documentation about setup features and custom commands.
|
13
|
+
- Reissue deprecated fragment_directory and added fragment.
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
|
17
|
+
- Got rid of the prepare release yml and action, only the Release gem to RubyGems.org is needed now.
|
18
|
+
- Got rid of the code climate action.
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Updated release documentation.
|
23
|
+
|
8
24
|
## [0.2.13] - 2025-09-02
|
9
25
|
|
10
26
|
### Added
|
@@ -19,9 +35,3 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
19
35
|
- Added debugging for OIDC.
|
20
36
|
- Switching back to version 1.0.0 for trusted publisher
|
21
37
|
- 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.
|
data/README.md
CHANGED
@@ -46,18 +46,18 @@ 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
53
|
### Changelog Fragments
|
54
54
|
|
55
|
-
Discharger supports changelog fragment management through the `
|
55
|
+
Discharger supports changelog fragment management through the `fragment` setting from [Reissue](https://github.com/SOFware/reissue?tab=readme-ov-file#configuration-options).
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
Discharger::Task.create do |task|
|
59
59
|
# ... other configuration ...
|
60
|
-
task.
|
60
|
+
task.fragment = "changelog.d" # Default: nil (disabled), or use :git
|
61
61
|
end
|
62
62
|
```
|
63
63
|
|
@@ -92,19 +92,194 @@ rake release:stage # ---------- STEP 2 ----------
|
|
92
92
|
2. **Stage** (`rake release:stage`): Update the staging branch and create a PR to production
|
93
93
|
3. **Release** (`rake release`): Release the current version to production by tagging and pushing to the production branch
|
94
94
|
|
95
|
+
### Building with a Working Branch
|
96
|
+
|
97
|
+
To release a specific working branch to stage instead of the default branch, use the `DISCHARGER_BUILD_BRANCH` environment variable:
|
98
|
+
|
99
|
+
```bash
|
100
|
+
DISCHARGER_BUILD_BRANCH=your-feature-branch rake build
|
101
|
+
```
|
102
|
+
|
103
|
+
This will deploy your working branch to the staging environment.
|
104
|
+
|
105
|
+
#### Configuring Branch Names
|
106
|
+
|
107
|
+
You can configure the branch names in your Rakefile when setting up the discharger task:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
require "discharger"
|
111
|
+
|
112
|
+
Discharger::Task.new do |task|
|
113
|
+
task.app_name = "MyApp"
|
114
|
+
task.working_branch = ENV.fetch("WORKING_BRANCH", "develop")
|
115
|
+
task.staging_branch = ENV.fetch("STAGING_BRANCH", "stage")
|
116
|
+
task.production_branch = ENV.fetch("PRODUCTION_BRANCH", "main")
|
117
|
+
# ... other configuration
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
121
|
+
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.
|
122
|
+
|
123
|
+
## Development Setup Automation
|
124
|
+
|
125
|
+
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.
|
126
|
+
|
127
|
+
### Running Setup
|
128
|
+
|
129
|
+
After installing Discharger, run the setup script to configure your development environment:
|
130
|
+
|
131
|
+
```bash
|
132
|
+
$ bin/setup
|
133
|
+
```
|
134
|
+
|
135
|
+
This script is idempotent - you can run it multiple times safely, and it will ensure your environment is properly configured.
|
136
|
+
|
137
|
+
### Configuration
|
138
|
+
|
139
|
+
The setup process is configured through `config/setup.yml`. Here's an example configuration:
|
140
|
+
|
141
|
+
```yaml
|
142
|
+
app_name: "YourAppName"
|
143
|
+
|
144
|
+
database:
|
145
|
+
port: 5432
|
146
|
+
name: "db-your-app"
|
147
|
+
version: "14"
|
148
|
+
password: "postgres"
|
149
|
+
|
150
|
+
redis:
|
151
|
+
port: 6379
|
152
|
+
name: "redis-your-app"
|
153
|
+
version: "latest"
|
154
|
+
|
155
|
+
# Built-in commands to run
|
156
|
+
steps:
|
157
|
+
- brew
|
158
|
+
- asdf
|
159
|
+
- git
|
160
|
+
- bundler
|
161
|
+
- yarn
|
162
|
+
- config
|
163
|
+
- docker
|
164
|
+
- env
|
165
|
+
- database
|
166
|
+
|
167
|
+
# Custom commands for your application
|
168
|
+
custom_steps:
|
169
|
+
- description: "Seed application data"
|
170
|
+
command: "bin/rails db:seed"
|
171
|
+
```
|
172
|
+
|
173
|
+
### Using Default Steps
|
174
|
+
|
175
|
+
The `steps` array specifies which built-in setup commands to run. Available commands include:
|
176
|
+
|
177
|
+
- `brew` - Install Homebrew dependencies
|
178
|
+
- `asdf` - Setup version management with asdf
|
179
|
+
- `git` - Configure git settings
|
180
|
+
- `bundler` - Install Ruby gems
|
181
|
+
- `yarn` - Install JavaScript packages
|
182
|
+
- `config` - Copy configuration files
|
183
|
+
- `docker` - Setup Docker containers
|
184
|
+
- `env` - Configure environment variables
|
185
|
+
- `database` - Setup and migrate database
|
186
|
+
|
187
|
+
### Selecting Specific Steps
|
188
|
+
|
189
|
+
You can customize which steps run by modifying the `steps` array:
|
190
|
+
|
191
|
+
```yaml
|
192
|
+
# Only run specific setup steps
|
193
|
+
steps:
|
194
|
+
- bundler
|
195
|
+
- database
|
196
|
+
- yarn
|
197
|
+
```
|
198
|
+
|
199
|
+
Leave the array empty or omit it entirely to run all available steps.
|
200
|
+
|
201
|
+
### Adding Custom Commands
|
202
|
+
|
203
|
+
Add application-specific setup tasks using the `custom_steps` section:
|
204
|
+
|
205
|
+
```yaml
|
206
|
+
custom_steps:
|
207
|
+
# Simple command
|
208
|
+
- description: "Compile assets"
|
209
|
+
command: "bin/rails assets:precompile"
|
210
|
+
|
211
|
+
# Command with condition
|
212
|
+
- description: "Setup Elasticsearch"
|
213
|
+
command: "bin/rails search:setup"
|
214
|
+
condition: "defined?(Elasticsearch)"
|
215
|
+
|
216
|
+
# Command with environment variable condition
|
217
|
+
- description: "Import production data"
|
218
|
+
command: "bin/rails db:import"
|
219
|
+
condition: "ENV['IMPORT_DATA'] == 'true'"
|
220
|
+
```
|
221
|
+
|
222
|
+
Each custom step can include:
|
223
|
+
- `description` - A description shown during setup
|
224
|
+
- `command` - The command to execute
|
225
|
+
- `condition` - An optional Ruby expression that must evaluate to true for the command to run
|
226
|
+
|
227
|
+
### Creating Custom Command Classes
|
228
|
+
|
229
|
+
For more complex setup logic, you can create custom command classes that integrate with Discharger's setup system:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
# lib/setup_commands/elasticsearch_command.rb
|
233
|
+
class ElasticsearchCommand < Discharger::SetupRunner::Commands::BaseCommand
|
234
|
+
def description
|
235
|
+
"Configure Elasticsearch"
|
236
|
+
end
|
237
|
+
|
238
|
+
def can_execute?
|
239
|
+
defined?(Elasticsearch)
|
240
|
+
end
|
241
|
+
|
242
|
+
def execute
|
243
|
+
with_spinner("Setting up Elasticsearch...") do
|
244
|
+
# Your setup logic here
|
245
|
+
system("bin/rails search:setup")
|
246
|
+
system("bin/rails search:reindex")
|
247
|
+
end
|
248
|
+
log "Elasticsearch configured successfully", emoji: "✅"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# Register the command in an initializer or your setup script
|
253
|
+
Discharger::SetupRunner.register_command(:elasticsearch, ElasticsearchCommand)
|
254
|
+
```
|
255
|
+
|
256
|
+
Then use it in your configuration:
|
257
|
+
|
258
|
+
```yaml
|
259
|
+
steps:
|
260
|
+
- bundler
|
261
|
+
- database
|
262
|
+
- elasticsearch # Your custom command
|
263
|
+
```
|
264
|
+
|
265
|
+
|
95
266
|
## Contributing
|
96
267
|
|
97
268
|
This gem is managed with [Reissue](https://github.com/SOFware/reissue).
|
98
269
|
|
99
270
|
### Releasing
|
100
271
|
|
101
|
-
Releases are
|
272
|
+
Releases are streamlined with a single GitHub Actions workflow using RubyGems Trusted Publishing:
|
102
273
|
|
103
|
-
1. Go to Actions → "
|
104
|
-
2. Select version type (
|
105
|
-
3.
|
106
|
-
|
107
|
-
|
274
|
+
1. Go to Actions → "Release gem to RubyGems.org" → Run workflow
|
275
|
+
2. Select version bump type (patch, minor, or major)
|
276
|
+
3. The workflow will automatically:
|
277
|
+
- Finalize the changelog with the release date
|
278
|
+
- Build the gem with checksum verification
|
279
|
+
- Publish to RubyGems.org via Trusted Publishing (no API keys needed)
|
280
|
+
- Create a git tag for the release
|
281
|
+
- Bump to the next development version
|
282
|
+
- Open a PR with the version bump for continued development
|
108
283
|
|
109
284
|
Bug reports and pull requests are welcome on GitHub.
|
110
285
|
|
@@ -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?
|
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