dante 0.3.0 → 0.4.1

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.
@@ -1,210 +0,0 @@
1
- # Publishes a dante release to rubygems.org with trusted publishing, gated by the "release"
2
- # environment: the owner approves each publish.
3
- #
4
- # Usual path: merge the release PR (the version in lib/dante/version.rb and the CHANGELOG.md heading
5
- # stamped with the date, e.g. "## 0.3.0 (2026-11-01)"), then "Run workflow" on master with the
6
- # version. build checks the version, that the changelog's first heading is that version with a date,
7
- # and the branch, and builds the gem reproducibly; publish waits for approval, pushes the gem with
8
- # short-lived trusted-publishing credentials, then creates the tag vX.Y.Z on the built commit. Pushing
9
- # a vX.Y.Z tag on a master commit runs the same checks. "Re-run failed jobs" (not "Re-run all jobs",
10
- # which rebuilds) resumes a release that stopped partway.
11
- # If the gem is pushed but the tag step keeps failing, push the tag by hand at the built commit: that
12
- # tag push's run skips the push (same sum).
13
- #
14
- # Dry run: tick dry_run to check the wiring. Everything runs except the changelog checks, the tag and
15
- # the push; the credential exchange fails unless the trusted publisher is set up.
16
- #
17
- # The "release" environment's protection rules are the ONLY gate on publishing (required reviewer, no
18
- # admin bypass, deployments only from master and v*.*.* tags): RubyGems trusts any run of this file
19
- # that uses that environment, and a branch or tag can carry its own modified copy of it. The trusted
20
- # publisher on rubygems.org must name the environment. Before approving a deployment, check
21
- # who started the run, the event, that the commit is the release PR's merge commit, and the build
22
- # log's "is on master" line. Reject any run you won't approve: a waiting run blocks the next one.
23
- # A deployment rule for X.Y-stable lets anyone with write access create such a branch carrying its own
24
- # copy of this file: add one only for a maintenance release, and remove it after.
25
-
26
- name: release
27
- run-name: release ${{ inputs.version || github.ref_name }}${{ inputs.dry_run && ' (dry run)' || '' }}
28
-
29
- on:
30
- push:
31
- tags: ['v[0-9]+.[0-9]+.[0-9]+']
32
- workflow_dispatch:
33
- inputs:
34
- version:
35
- description: 'Version to release (already in the version file of this branch), e.g. 1.2.0'
36
- required: true
37
- type: string
38
- dry_run:
39
- description: 'Dry run: check, build and exchange credentials, but create no tag and push nothing'
40
- required: false
41
- type: boolean
42
- default: false
43
-
44
- permissions:
45
- contents: read
46
-
47
- concurrency:
48
- group: release
49
- cancel-in-progress: false
50
-
51
- jobs:
52
- build:
53
- if: github.repository == 'nesquena/dante'
54
- runs-on: ubuntu-latest
55
- env:
56
- TRUNK: master
57
- TAG_PREFIX: v
58
- GEMS: 'dante:.'
59
- VERSION_FILE: lib/dante/version.rb
60
- CHANGELOG: CHANGELOG.md
61
- CHANGELOG_HEADING: '^## '
62
- CHANGELOG_TOP: '^## ([0-9]+\.[0-9]+\.[0-9]+)( |$)'
63
- outputs:
64
- version: ${{ steps.check.outputs.version }}
65
- tag: ${{ steps.check.outputs.tag }}
66
- steps:
67
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
68
- with:
69
- fetch-depth: 0
70
- submodules: true
71
- persist-credentials: false
72
- - uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
73
- with:
74
- ruby-version: '3.3'
75
- - name: Check the version
76
- id: check
77
- shell: bash -eo pipefail {0}
78
- env:
79
- INPUT_VERSION: ${{ inputs.version }}
80
- DRY_RUN: ${{ inputs.dry_run }}
81
- run: |
82
- if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
83
- version="$INPUT_VERSION"
84
- [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::the version input is not a plain version like 1.2.3"; exit 1; }
85
- case "$GITHUB_REF" in
86
- "refs/heads/$TRUNK"|"refs/heads/${version%.*}-stable") ;;
87
- *) echo "::error::run this on $TRUNK or ${version%.*}-stable, not $GITHUB_REF"; exit 1 ;;
88
- esac
89
- tag="$TAG_PREFIX$version"
90
- tagged=$(git ls-remote origin "refs/tags/$tag*" | awk -v t="refs/tags/$tag" '$2 == t || $2 == t "^{}" { print $1 }')
91
- [ -z "$tagged" ] || echo "$tagged" | grep -qx "$GITHUB_SHA" ||
92
- { echo "::error::tag $tag already exists at another commit"; exit 1; }
93
- else
94
- tag="$GITHUB_REF_NAME"
95
- version="${tag#"$TAG_PREFIX"}"
96
- [[ "$tag" == "$TAG_PREFIX"* && "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::tag $tag is not ${TAG_PREFIX}X.Y.Z"; exit 1; }
97
- fi
98
- file_version=$(ruby -e 'puts File.binread(ENV["VERSION_FILE"])[/\bVERSION\s*=\s*["\x27]([^"\x27]+)/, 1]')
99
- [ "$version" = "$file_version" ] || { echo "::error::version $version but $VERSION_FILE says $file_version"; exit 1; }
100
- if [ "$DRY_RUN" = true ]; then
101
- echo "::warning::dry run: not checking $CHANGELOG"
102
- else
103
- heading=$(grep -m1 -E "$CHANGELOG_HEADING" "$CHANGELOG") || { echo "::error::$CHANGELOG has no heading matching '$CHANGELOG_HEADING'"; exit 1; }
104
- top=$(echo "$heading" | sed -nE "s/$CHANGELOG_TOP.*/\1/p")
105
- [ "$top" = "$version" ] || { echo "::error::$CHANGELOG starts with '$heading', not release $version: merge the release PR first, and nothing after it"; exit 1; }
106
- rest="${heading#*"$version"}"
107
- [[ "$rest" =~ (19|20)[0-9][0-9] ]] && ! echo "$rest" | grep -qiwE 'unreleased|tbd|tba' ||
108
- { echo "::error::$CHANGELOG's '$heading' isn't stamped with a date yet"; exit 1; }
109
- fi
110
- series="${version%.*}-stable"
111
- on=""
112
- for b in "$series" "$TRUNK"; do
113
- git merge-base --is-ancestor "$GITHUB_SHA" "refs/remotes/origin/$b" 2>/dev/null && on="$b"
114
- done
115
- [ -n "$on" ] || { echo "::error::$version ($GITHUB_SHA) is not on $TRUNK or $series"; exit 1; }
116
- echo "version=$version" >> "$GITHUB_OUTPUT"
117
- echo "tag=$tag" >> "$GITHUB_OUTPUT"
118
- echo "$version ($GITHUB_SHA) is on $on"
119
- - name: Build the gems
120
- shell: bash -eo pipefail {0}
121
- env:
122
- VERSION: ${{ steps.check.outputs.version }}
123
- run: |
124
- SOURCE_DATE_EPOCH=$(git log -1 --format=%ct "$GITHUB_SHA"); export SOURCE_DATE_EPOCH
125
- mkdir dist
126
- for spec in $GEMS; do
127
- g="${spec%%:*}"; dir="${spec#*:}"; [ "$dir" = "$spec" ] && dir=.
128
- out="$GITHUB_WORKSPACE/dist/$g-$VERSION.gem"
129
- (cd "$dir" && gem build "$g.gemspec" --output "$out")
130
- [ "$(gem spec "$out" name)" = "--- $g" ] && [ "$(gem spec "$out" version | sed -n 's/^version: //p')" = "$VERSION" ] ||
131
- { echo "::error::$out is not $g $VERSION:"; gem spec "$out" name; gem spec "$out" version; exit 1; }
132
- echo "$g" >> dist/ORDER
133
- done
134
- echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH (ruby $(ruby -e 'print RUBY_VERSION'), rubygems $(gem -v))"
135
- (cd dist && sha256sum *.gem > SHA256SUMS && cat ORDER SHA256SUMS)
136
- - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
137
- with:
138
- name: gems-${{ steps.check.outputs.version }}
139
- path: dist/
140
- if-no-files-found: error
141
-
142
- publish:
143
- needs: build
144
- runs-on: ubuntu-latest
145
- environment: release
146
- permissions:
147
- contents: write # creates the tag on a dispatched release
148
- id-token: write # the RubyGems trusted-publishing exchange
149
- steps:
150
- - name: Refuse a stale run (the tag is somewhere else)
151
- shell: bash -eo pipefail {0}
152
- env:
153
- TAG: ${{ needs.build.outputs.tag }}
154
- run: |
155
- tagged=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/tags/$TAG*" |
156
- awk -v t="refs/tags/$TAG" '$2 == t || $2 == t "^{}" { print $1 }')
157
- if [ -z "$tagged" ] && [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
158
- echo "tag $TAG will be created at $GITHUB_SHA"
159
- else
160
- echo "$tagged" | grep -qx "$GITHUB_SHA" || { echo "::error::tag $TAG is not at $GITHUB_SHA (now: ${tagged:-gone}); this run is stale"; exit 1; }
161
- fi
162
- - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
163
- with:
164
- name: gems-${{ needs.build.outputs.version }}
165
- path: dist
166
- - name: Check the sums
167
- working-directory: dist
168
- run: sha256sum -c SHA256SUMS
169
- - uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
170
- with:
171
- ruby-version: '3.3'
172
- - uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
173
- - name: Dry run ends here
174
- if: inputs.dry_run
175
- run: echo "Credentials exchange succeeded, so the trusted publisher works. No tag created, nothing pushed."
176
- - name: Push the gems
177
- if: ${{ !inputs.dry_run }}
178
- shell: bash -eo pipefail {0}
179
- working-directory: dist
180
- env:
181
- VERSION: ${{ needs.build.outputs.version }}
182
- run: |
183
- while read -r g; do
184
- sum=$(sha256sum "$g-$VERSION.gem" | cut -d' ' -f1)
185
- published=$(curl -fsS "https://rubygems.org/api/v1/versions/$g.json" 2>/dev/null |
186
- ruby -rjson -e 'b = $stdin.read; v = (b.empty? ? [] : JSON.parse(b)).find { |x| x["number"] == ENV["VERSION"] && x["platform"] == "ruby" }; print v ? v["sha"].to_s : ""' || true)
187
- if [ -z "$published" ]; then
188
- gem push "$g-$VERSION.gem" </dev/null
189
- elif [ "$published" = "$sum" ]; then
190
- echo "$g $VERSION is already on rubygems.org with this sum; skipping"
191
- else
192
- echo "::error::$g $VERSION is already on rubygems.org with sha256 $published, not this build's $sum"; exit 1
193
- fi
194
- done < ORDER
195
- - name: Create the tag
196
- if: github.event_name == 'workflow_dispatch' && !inputs.dry_run
197
- shell: bash -eo pipefail {0}
198
- env:
199
- TAG: ${{ needs.build.outputs.tag }}
200
- GH_TOKEN: ${{ github.token }}
201
- run: |
202
- tagged=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY" "refs/tags/$TAG*" |
203
- awk -v t="refs/tags/$TAG" '$2 == t || $2 == t "^{}" { print $1 }')
204
- if [ -z "$tagged" ]; then
205
- gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$GITHUB_SHA"
206
- elif echo "$tagged" | grep -qx "$GITHUB_SHA"; then
207
- echo "tag $TAG is already at $GITHUB_SHA"
208
- else
209
- echo "::error::tag $TAG is not at $GITHUB_SHA (now: $tagged)"; exit 1
210
- fi
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in dante.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- # require 'yard'
4
-
5
- TEST_FILES = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)]
6
-
7
- Rake::TestTask.new do |t|
8
- t.libs.push "lib"
9
- t.test_files = TEST_FILES
10
- t.verbose = true
11
- end
12
-
13
- # Rake::TestTask treats an empty file list as a passing run of nothing.
14
- task :test_files_present do
15
- abort "No test files match test/**/*_test.rb" if TEST_FILES.empty?
16
- end
17
- task :test => :test_files_present
18
-
19
- task :default => :test
20
-
21
- # task :doc do
22
- # YARD::CLI::Yardoc.new.run
23
- # end
data/dante.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "dante/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "dante"
7
- s.version = Dante::VERSION
8
- s.authors = ["Nathan Esquenazi"]
9
- s.email = ["nesquena@gmail.com"]
10
- s.homepage = "https://github.com/nesquena/dante"
11
- s.summary = %q{Turn any process into a demon}
12
- s.description = %q{Turn any process into a demon.}
13
- s.license = "MIT"
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
- s.required_ruby_version = '>= 2.7'
20
-
21
- s.add_development_dependency 'rake'
22
- s.add_development_dependency 'minitest', '>= 5.0'
23
- end
data/test/dante_test.rb DELETED
@@ -1,16 +0,0 @@
1
- require File.expand_path('../test_helper', __FILE__)
2
-
3
- describe "dante module" do
4
- before do
5
- @process = TestingProcess.new('a', @tmpdir)
6
- end
7
-
8
- it "can run jobs using #run method" do
9
- capture_stdout do
10
- Dante.run('test-process') { @process.run_a! }
11
- end
12
- @output = File.read(@process.tmp_path)
13
- assert_match(/Started/, @output)
14
- end
15
-
16
- end