elelem-github 0.1.0 → 0.2.0

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: d9dd99a699553a31ac65aa6ec33b977e8135cf06441c9eb2f8d2689350f0e20c
4
- data.tar.gz: 1badc70d2180a9641ba7dc8109c3adcd3b999e1ece54253ac9e816d2cc3c4801
3
+ metadata.gz: 54641c93da46120d60a89d770f1eaa0ff7089e9c2c795f3428d0f606002197b0
4
+ data.tar.gz: 96256b2a8a9763c7a93d509db4aa1565b511f5479843f861a08ef01ab774d322
5
5
  SHA512:
6
- metadata.gz: e69fe564477de20fb09482a9614d0e9e0abc4fb6943dae714452f379aa270ead3d6ab3be00430d4cd1dd5e21846b06fbefdddb44cbd2776d0a326e1a53ee87a1
7
- data.tar.gz: fe8296fbb80f0181cdc9a3aa22865339577661f7c5f486e02b0e99dd1f46b6caed942735afed2e375f05c5b1cd2fd3b3e38589275d380eb42226b3bae016e4f9
6
+ metadata.gz: 5e7c34bd1f658b7f593a9eb9f1a4415552cad57ca225178bc1e903ef4cbdceb44cacfbbed4055fe21316b2d304fcff3e854140a1dbbed0eb4bc964abb2d437f2
7
+ data.tar.gz: a67b5663294b6564d3e44868f8fce6a8f5792db1d2d16360fba61439c392061adfd1e40eea4b92a9d607b5da513cab7c82b305bb0687537f3930e9ff5534c7fc
@@ -59,16 +59,6 @@ jobs:
59
59
  with:
60
60
  ruby-version: "4.0"
61
61
  bundler-cache: true
62
- - shell: bash
63
- run: |
64
- set -euo pipefail
65
- jwt=$(curl -sS --fail-with-body -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=rubygems.org" | jq -r .value)
66
- echo "::add-mask::$jwt"
67
- key=$(jq -n --arg jwt "$jwt" '{jwt: $jwt, owner: "66898"}' | curl -sS --fail-with-body -H "content-type: application/json" -d @- https://rubygems.org/api/v1/oidc/trusted_publisher/exchange_token | jq -r .rubygems_api_key)
68
- test -n "$key" -a "$key" != null
69
- echo "::add-mask::$key"
70
- printf 'GEM_HOST_API_KEY=%s\nBUNDLE_GEM__PUSH_KEY=%s\nRUBYGEMS_API_KEY=%s\n' "$key" "$key" "$key" >> "$GITHUB_ENV"
71
62
  - uses: rubygems/release-gem@7f9650160c1a4e7989fdc9855807bdbd421d8b6b # v1.4.1
72
63
  with:
73
- setup-trusted-publisher: false
74
64
  await-release: false
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.1.0"
2
+ ".": "0.2.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/elelem-sh/github/compare/v0.1.0...v0.2.0) (2026-11-17)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * read GH_TOKEN or GITHUB_TOKEN, the names gh and GitHub Models use, instead of GITHUB_API_KEY
9
+
10
+ ### Features
11
+
12
+ * read GH_TOKEN or GITHUB_TOKEN, the names gh and GitHub Models use, instead of GITHUB_API_KEY ([27f18cc](https://github.com/elelem-sh/github/commit/27f18cce15c53a180cca7d58e77c6c7e8963b601))
13
+
3
14
  ## 0.1.0 (2026-11-16)
4
15
 
5
16
 
data/README.md CHANGED
@@ -13,11 +13,11 @@ gem install elelem-github
13
13
  ## Use
14
14
 
15
15
  ```sh
16
- export GITHUB_API_KEY=...
16
+ export GITHUB_TOKEN=...
17
17
  elelem -p github --model MODEL
18
18
  ```
19
19
 
20
- * `GITHUB_API_KEY` (required): a GitHub token with the `models:read` permission, from https://github.com/settings/tokens
20
+ * `GH_TOKEN` or `GITHUB_TOKEN` (required, `GH_TOKEN` wins, as in `gh`): a GitHub token with the `models:read` permission, from https://github.com/settings/tokens
21
21
  * `GITHUB_MODEL`: the model, when `--model` is not given
22
22
  * `GITHUB_BASE_URL`: overrides `https://models.github.ai/inference`
23
23
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Elelem
4
4
  module GitHub
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/elelem/github.rb CHANGED
@@ -8,8 +8,8 @@ Elelem.configure do |config|
8
8
  config.provider(:github) do |model: nil, **|
9
9
  # A variable that is set but empty counts as unset.
10
10
  env = ->(name) { ENV[name].to_s.strip.then { |v| v.empty? ? nil : v } }
11
- key = env.call("GITHUB_API_KEY")
12
- raise KeyError, "GITHUB_API_KEY is not set" if key.nil?
11
+ key = env.call("GH_TOKEN") || env.call("GITHUB_TOKEN")
12
+ raise KeyError, "GH_TOKEN or GITHUB_TOKEN is not set" if key.nil?
13
13
 
14
14
  model = env.call("GITHUB_MODEL") if model.to_s.strip.empty?
15
15
  raise KeyError, "GITHUB_MODEL is not set. Pass --model or set GITHUB_MODEL" if model.nil?
@@ -2,15 +2,16 @@
2
2
 
3
3
  RSpec.describe "the github provider" do
4
4
  around do |example|
5
- saved = ENV.to_h.slice("GITHUB_API_KEY", "GITHUB_BASE_URL", "GITHUB_MODEL")
5
+ saved = ENV.to_h.slice("GH_TOKEN", "GITHUB_TOKEN", "GITHUB_BASE_URL", "GITHUB_MODEL")
6
6
  example.run
7
7
  ensure
8
- %w[GITHUB_API_KEY GITHUB_BASE_URL GITHUB_MODEL].each { |k| ENV.delete(k) }
8
+ %w[GH_TOKEN GITHUB_TOKEN GITHUB_BASE_URL GITHUB_MODEL].each { |k| ENV.delete(k) }
9
9
  ENV.update(saved)
10
10
  end
11
11
 
12
12
  before do
13
- ENV["GITHUB_API_KEY"] = "test-key"
13
+ ENV.delete("GH_TOKEN")
14
+ ENV["GITHUB_TOKEN"] = "test-key"
14
15
  ENV["GITHUB_MODEL"] = "env-model"
15
16
  ENV.delete("GITHUB_BASE_URL")
16
17
  end
@@ -18,6 +19,7 @@ RSpec.describe "the github provider" do
18
19
  def build(**) = Elelem::Config.build_provider("github", **)
19
20
  def uri(**) = build(**).instance_variable_get(:@uri).to_s
20
21
  def model(**) = build(**).instance_variable_get(:@model)
22
+ def key = build.instance_variable_get(:@api_key)
21
23
 
22
24
  it "registers provider github" do
23
25
  expect(Elelem::Config.names).to include("github")
@@ -28,16 +30,22 @@ RSpec.describe "the github provider" do
28
30
  expect(uri).to eq("https://models.github.ai/inference/chat/completions")
29
31
  end
30
32
 
31
- it "sends GITHUB_API_KEY" do
32
- expect(build.instance_variable_get(:@api_key)).to eq("test-key")
33
+ it "sends GITHUB_TOKEN" do
34
+ expect(key).to eq("test-key")
33
35
  end
34
36
 
35
- it "names GITHUB_API_KEY when the key is missing or empty" do
36
- ENV.delete("GITHUB_API_KEY")
37
- expect { build }.to raise_error(KeyError, /GITHUB_API_KEY/)
37
+ it "prefers GH_TOKEN over GITHUB_TOKEN, as gh does" do
38
+ ENV["GH_TOKEN"] = "gh-key"
39
+ expect(key).to eq("gh-key")
40
+ end
41
+
42
+ it "names both variables when the token is missing or empty" do
43
+ ENV.delete("GITHUB_TOKEN")
44
+ expect { build }.to raise_error(KeyError, /GH_TOKEN or GITHUB_TOKEN/)
38
45
 
39
- ENV["GITHUB_API_KEY"] = " "
40
- expect { build }.to raise_error(KeyError, /GITHUB_API_KEY/)
46
+ ENV["GITHUB_TOKEN"] = " "
47
+ ENV["GH_TOKEN"] = ""
48
+ expect { build }.to raise_error(KeyError, /GH_TOKEN or GITHUB_TOKEN/)
41
49
  end
42
50
 
43
51
  it "names GITHUB_MODEL when no model is set, and treats an empty one as unset" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elelem-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan