logtail 0.1.18 → 0.1.19

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: 93f4739daeaac5fe30db5251e9463e4139adcb9fe1bb5cc06988bd2617827d1c
4
- data.tar.gz: 7de7ff6b0b83de585e95c70c2fea5ce2e2c7067592d6f18f8d139db665525c75
3
+ metadata.gz: cd895e734e1d553b0dfdf1011f0a46b6f043a50c391d27822ee015a517759650
4
+ data.tar.gz: 964ab22275d822db5df10f3a4616e25d500b0d9292057ea26f4467be40786e63
5
5
  SHA512:
6
- metadata.gz: 80fe56d644e5f07108859de6399c29f16fd26b7294b5ea63bc8b710b4ad9de757048e61c89e3e27837643c61d63525c79c60d9384c338c410daf8dacc840cac4
7
- data.tar.gz: 64b96d54f5531470e8b87cb0e2ba4515266b25a5c03c20828cc3d1fb8e21ac81dc686057ac4b927b5bb55f571ef7c1f1b0e22265eaf342e5302d746d00ff0222
6
+ metadata.gz: 6556a1a6135a0c12070fab2080f43800e48fc0c7acfebab062d70ccc99999dadcbcb913145312d3fd61a0a5ad9f3ab411e6017a2cfe5cb55988867f882a748ec
7
+ data.tar.gz: 10e8559ff2347820d3e7d0af52c019fbdd84c82507653f232b33e1bfdd9cd35382ba04a109537e6c537b429df857e0383bd2b3930cd60f576d121fb1e1f0f5ab
@@ -1,10 +1,11 @@
1
- # Publishes the gem to RubyGems.org from GitHub Actions, the way logtail-js and logtail-python
2
- # release their packages. The publish job runs in the "rubygems" environment, which only deploys
3
- # from main; anyone who can dispatch the workflow can release.
1
+ # Publishes the gem to RubyGems.org from GitHub Actions with trusted publishing (OIDC), the way
2
+ # logtail-js releases the @logtail/* packages to npm. No RubyGems.org API key exists anywhere:
3
+ # the gem on rubygems.org trusts exactly this workflow file, run from this repository in the
4
+ # "rubygems" environment, and the shared account's multi-factor authentication stays as it is.
4
5
  #
5
- # Authentication: the repository secret RUBYGEMS_CREDENTIALS holds the contents of a gem
6
- # credentials file for the shared rubygems.org account, i.e. ":rubygems_api_key: rubygems_…",
7
- # the line the manual process kept in ~/.local/share/gem/credentials.
6
+ # One-time setup on rubygems.org, signed in as the gem's owner: the gem's page → Trusted publishers
7
+ # → GitHub Actions, with the repository owner "logtail", this repository's name, the workflow
8
+ # "release.yml" and the environment "rubygems".
8
9
  #
9
10
  # Repository settings this relies on: the "rubygems" environment with deployment branches limited
10
11
  # to main and no required reviewers (add reviewers there if releases should need an approval; a
@@ -17,15 +18,17 @@
17
18
  # both, pushes the gem to RubyGems.org and creates a GitHub release with auto-generated notes for
18
19
  # the tag; edit the notes afterwards if needed.
19
20
  #
20
- # Retry: if a release failed after the version commit was pushed, run "retry" right away from
21
- # main. It bumps nothing, rebuilds the tagged commit, pushes the gem if RubyGems.org is still
22
- # missing it and creates the GitHub release if it is still missing. Running patch or minor again
23
- # would release the next version instead.
21
+ # Retry: if a release failed after the version commit was pushed, run "retry" from main. It bumps
22
+ # nothing, checks out the tag of the version in lib/*/version.rb and rebuilds that commit, pushes
23
+ # the gem if RubyGems.org is still missing it and creates the GitHub release if it is still
24
+ # missing. Running patch or minor again would release the next version instead.
24
25
  #
25
- # Dry run: bumps in place without committing, builds the gem and checks the credentials secret,
26
- # publishes nothing. Every push that touches this file is a dry run, so a change to the workflow
27
- # proves itself on its pull request before it reaches main. A dry run can also be dispatched from
28
- # any branch.
26
+ # Dry run: bumps in place without committing, builds the gem and, on main, exchanges the
27
+ # workflow's OIDC token with RubyGems.org, which proves that the trusted publisher matches this
28
+ # workflow. Nothing is pushed. Every push that touches this file is a dry run, so a change to the
29
+ # workflow proves itself on its pull request before it reaches main, and the push that merges it
30
+ # performs the token exchange as well, because the "rubygems" environment only admits main. A dry
31
+ # run can also be dispatched from any branch.
29
32
  name: Release
30
33
 
31
34
  on:
@@ -37,7 +40,7 @@ on:
37
40
  options: [patch, minor, retry]
38
41
  required: true
39
42
  dry_run:
40
- description: "Dry run: bump and build, check the credentials, publish nothing"
43
+ description: "Dry run: bump and build, verify RubyGems.org accepts this workflow, publish nothing"
41
44
  type: boolean
42
45
  default: false
43
46
  push:
@@ -108,7 +111,9 @@ jobs:
108
111
  tagged = `git tag --points-at HEAD`.split.include?("v#{current}")
109
112
 
110
113
  if release == "retry"
111
- abort("retry only finishes a release whose version commit v#{current} is HEAD") unless tagged
114
+ # main may have moved on since the version commit, so build what the tag points at
115
+ abort("retry only finishes a release whose version v#{current} is tagged") unless system("git", "rev-parse", "-q", "--verify", "refs/tags/v#{current}", out: File::NULL)
116
+ system("git", "checkout", "-q", "v#{current}") || abort("could not check out v#{current}")
112
117
  version = current
113
118
  else
114
119
  abort("HEAD is already released as v#{current}, there is nothing new to release") if tagged && !dry_run
@@ -126,6 +131,7 @@ jobs:
126
131
  env:
127
132
  VERSION: ${{ steps.version.outputs.version }}
128
133
  run: |
134
+ git diff --stat
129
135
  gem build *.gemspec
130
136
  gem=$(ls *.gem)
131
137
  case "$gem" in
@@ -134,18 +140,6 @@ jobs:
134
140
  esac
135
141
  echo "gem=$gem" >> "$GITHUB_OUTPUT"
136
142
 
137
- - name: Dry run
138
- if: ${{ env.DRY_RUN == 'true' }}
139
- env:
140
- RUBYGEMS_CREDENTIALS: ${{ secrets.RUBYGEMS_CREDENTIALS }}
141
- run: |
142
- git diff --stat
143
- if ! grep -q '^:rubygems_api_key: [^ ]' <<< "$RUBYGEMS_CREDENTIALS"; then
144
- echo "::error::The RUBYGEMS_CREDENTIALS secret must hold the contents of a gem credentials file: ':rubygems_api_key: rubygems_…'"
145
- exit 1
146
- fi
147
- echo "RUBYGEMS_CREDENTIALS looks like a gem credentials file. A release pushes with it, nothing more to verify without pushing."
148
-
149
143
  - name: Commit and tag
150
144
  if: ${{ env.DRY_RUN != 'true' && env.RELEASE != 'retry' }}
151
145
  env:
@@ -166,11 +160,13 @@ jobs:
166
160
  release:
167
161
  name: Publish
168
162
  needs: build
169
- if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dry_run }}
163
+ # The rubygems environment only admits main, so dry runs from other branches stop after the build
164
+ if: ${{ github.ref == 'refs/heads/main' }}
170
165
  runs-on: ubuntu-24.04
171
166
  environment: rubygems
172
167
  permissions:
173
168
  contents: write # creates the GitHub release
169
+ id-token: write # OIDC token exchange with RubyGems.org
174
170
  env:
175
171
  VERSION: ${{ needs.build.outputs.version }}
176
172
  GEM: ${{ needs.build.outputs.gem }}
@@ -185,20 +181,28 @@ jobs:
185
181
  with:
186
182
  ruby-version: "3"
187
183
 
184
+ # Exchanges the job's OIDC token for a short-lived RubyGems.org API key and hands it to
185
+ # `gem push`. Fails when no trusted publisher on rubygems.org matches this workflow.
186
+ - uses: rubygems/configure-rubygems-credentials@v2.1.0
187
+
188
+ - name: Dry run
189
+ if: ${{ env.DRY_RUN == 'true' }}
190
+ run: |
191
+ ls -l "$GEM"
192
+ echo "RubyGems.org accepted the OIDC token: the trusted publisher matches this workflow. Nothing is pushed."
193
+
188
194
  - name: Push to RubyGems.org
189
- env:
190
- RUBYGEMS_CREDENTIALS: ${{ secrets.RUBYGEMS_CREDENTIALS }}
195
+ if: ${{ env.DRY_RUN != 'true' }}
191
196
  run: |
192
197
  name="${GEM%-$VERSION.gem}"
193
198
  if gem specification --remote "$name" --version "$VERSION" > /dev/null 2>&1; then
194
199
  echo "$name $VERSION is on rubygems.org already, finishing the release."
195
200
  else
196
- mkdir -p ~/.gem
197
- (umask 077 && printf '%s\n' "$RUBYGEMS_CREDENTIALS" > ~/.gem/credentials)
198
201
  gem push "$GEM"
199
202
  fi
200
203
 
201
204
  - name: Create GitHub release
205
+ if: ${{ env.DRY_RUN != 'true' }}
202
206
  env:
203
207
  GH_TOKEN: ${{ github.token }}
204
208
  GH_REPO: ${{ github.repository }}
@@ -119,13 +119,13 @@ module Logtail
119
119
  # Closes the log device, cleans up, and attempts one last delivery.
120
120
  def close
121
121
  # Kill the flush thread immediately since we are about to flush again.
122
- @flush_thread.kill if @flush_thread
122
+ @flush_thread.kill.join if @flush_thread
123
123
 
124
124
  # Flush all remaining messages
125
125
  flush
126
126
 
127
127
  # Kill the request queue thread. Flushing ensures that no requests are pending.
128
- @request_outlet_thread.kill if @request_outlet_thread
128
+ @request_outlet_thread.kill.join if @request_outlet_thread
129
129
  end
130
130
 
131
131
  def deliver_one(msg)
@@ -1,3 +1,3 @@
1
1
  module Logtail
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.19"
3
3
  end
@@ -57,10 +57,8 @@ describe Logtail::LogDevices::HTTP do
57
57
  http.send(:ensure_flush_threads_are_started)
58
58
  http.close
59
59
  thread = http.instance_variable_get(:@flush_thread)
60
- sleep 0.1 # too fast!
61
60
  expect(thread).to_not be_alive
62
61
  thread = http.instance_variable_get(:@request_outlet_thread)
63
- sleep 0.1 # too fast!
64
62
  expect(thread).to_not be_alive
65
63
  end
66
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Better Stack