Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
matrix:
ruby: ["3.1", "3.2", "3.3", "3.4"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
80 changes: 67 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,88 @@
---
# Publishes the gem to RubyGems.org when a vX.Y.Z tag is pushed, with RubyGems
# trusted publishing (no API key stored in GitHub).
# Publishes the gem to RubyGems.org when a vX.Y.Z tag is pushed, using
# RubyGems trusted publishing (no API key stored in GitHub).
#
# Before the first release, add a trusted publisher on rubygems.org:
# rubygems.org, your profile, Trusted publishers (or "pending trusted publishers" for a new gem)
# repository: noderings/knife-noderings, workflow: release.yml, environment: rubygems
# The first release uses a pending trusted publisher on the noderings
# RubyGems.org account (immutable owner ID 256963). After that, the same
# workflow stays as a trusted publisher on the gem.
#
# To retry, open Actions, Release, "Run workflow", and pick the tag under
# "Use workflow from".
name: release

"on":
push:
tags: ["v*.*.*"]
workflow_dispatch:

permissions:
contents: write
contents: read
id-token: write

concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false

env:
TAG: ${{ github.ref_name }}
GEM_NAME: knife-noderings

jobs:
rubygems:
name: Push to RubyGems.org
runs-on: ubuntu-latest
environment: rubygems
timeout-minutes: 15
permissions:
contents: write
id-token: write
environment:
name: rubygems
url: https://rubygems.org/gems/knife-noderings
steps:
- uses: actions/checkout@v4
- name: Check this runs for a version tag
run: |
case "${TAG}" in
v[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "::error::Run this workflow from a vX.Y.Z tag, not ${TAG}."; exit 1 ;;
esac
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check the tag matches the gem version
run: |
version=$(sed -n 's/.*VERSION = "\([^"]*\)".*/\1/p' lib/knife-noderings/version.rb | head -1)
test "v${version}" = "${TAG}" || { echo "::error::Tag ${TAG} does not match gem version ${version}."; exit 1; }
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- uses: rubygems/release-gem@v1
- name: Check the version is not on RubyGems yet
id: exists
run: |
version="${TAG#v}"
code=$(curl -s -o /dev/null -w '%{http_code}' "https://rubygems.org/api/v2/rubygems/${GEM_NAME}/versions/${version}.json")
if [ "${code}" = "200" ]; then
echo "::notice::${GEM_NAME} ${version} is already on RubyGems.org, nothing to push."
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
# owner is required for the first push of a pending trusted publisher.
- uses: rubygems/configure-rubygems-credentials@c6ca7f4bac0e29c9bde8eeae0a0a986b27efa05f # v2.2.0
if: steps.exists.outputs.published != 'true'
with:
await-release: true
- name: GitHub release
owner: "256963"
- name: Build and push the gem
if: steps.exists.outputs.published != 'true'
run: |
version="${TAG#v}"
gem build "${GEM_NAME}.gemspec"
gem push "${GEM_NAME}-${version}.gem"
- name: Publish the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes "See CHANGELOG.md." --verify-tag || true
GH_REPO: ${{ github.repository }}
run: |
if ! gh release view "${TAG}" >/dev/null 2>&1; then
gh release create "${TAG}" --verify-tag --draft --title "${TAG}" --notes "See CHANGELOG.md."
fi
gh release edit "${TAG}" --draft=false --latest
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ export `NODERINGS_TOKEN`, and run `knife noderings server list`, or `knife noder
billed servers.

Please report security problems privately as described in [SECURITY.md](SECURITY.md).

## Releases

Push a `vX.Y.Z` tag that matches `KnifeNoderings::VERSION` (or merge the
release-please pull request once that workflow is in place). The tag starts
`.github/workflows/release.yml`, which publishes the gem to
[RubyGems.org](https://rubygems.org/gems/knife-noderings) with trusted
publishing and then publishes the GitHub release.

The first push of a new gem must pass the RubyGems.org account ID (`owner: "256963"`)
when exchanging the OIDC token, as already set in `release.yml`. To retry a
release, open Actions, Release, *Run workflow*, and pick the tag under
*Use workflow from*.
11 changes: 6 additions & 5 deletions knife-noderings.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = KnifeNoderings::VERSION
s.authors = ["NodeRings"]
s.email = ["partners@noderings.com"]
s.homepage = "https://github.com/noderings/knife-noderings"
s.homepage = "https://noderings.com"
s.summary = "NodeRings support for Chef's knife: order, bootstrap and manage NodeRings servers"
s.description = "A knife plugin that orders NodeRings virtual machines from the marketplace and bootstraps " \
"Chef Infra or Cinc on them, and lists, shows, powers and deletes them."
Expand All @@ -17,12 +17,13 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.required_ruby_version = ">= 3.1"

source_code = "https://github.com/noderings/knife-noderings"
s.metadata = {
"bug_tracker_uri" => "#{s.homepage}/issues",
"changelog_uri" => "#{s.homepage}/blob/main/CHANGELOG.md",
"documentation_uri" => "#{s.homepage}#readme",
"bug_tracker_uri" => "#{source_code}/issues",
"changelog_uri" => "#{source_code}/blob/main/CHANGELOG.md",
"documentation_uri" => "#{source_code}#readme",
"homepage_uri" => s.homepage,
"source_code_uri" => s.homepage,
"source_code_uri" => source_code,
"rubygems_mfa_required" => "true",
}

Expand Down