Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3e081e2
Control type of release and tagging
markpitchless Apr 14, 2021
02cb8ab
Pull out the bash to it's own script
markpitchless Apr 15, 2021
2474662
Add pushed-version output
markpitchless Apr 15, 2021
41d931f
Docs for new options
markpitchless Apr 15, 2021
200d4a5
Version v1.1.0
markpitchless Apr 15, 2021
7d07098
Review: add docs on ruby requirements
markpitchless Apr 15, 2021
659a9b3
Review: better messages when skipping push
markpitchless Apr 15, 2021
fbf77e0
Merge pull request #2 from fac/devp/v1.1.0
markpitchless Apr 15, 2021
09563f0
v1.2.0 rename to ruby-gem-push-action
markpitchless Apr 15, 2021
727057e
Merge pull request #3 from fac/devp/v1.2.0
markpitchless Apr 15, 2021
72934f9
Clean up gem push output handling
markpitchless Apr 15, 2021
68f4b2e
Merge pull request #4 from fac/devp/v1.2.1
markpitchless Apr 16, 2021
8c659ce
Version v1.3.0
markpitchless Apr 16, 2021
3571ffe
Merge pull request #5 from fac/devp/v1.3.0
markpitchless Apr 16, 2021
2fde64a
Pull the gemhost out of the spec
markpitchless Apr 17, 2021
ceea7da
Add key-name input
markpitchless Apr 18, 2021
4c5df94
Rename input to just key
markpitchless Apr 18, 2021
7edee15
Remove release option, make pre-release input either or.
markpitchless Apr 18, 2021
af505be
Pass inputs as command line opts
markpitchless Apr 18, 2021
37f190e
Clean up option/input names
markpitchless Apr 18, 2021
b55d859
Update docs to match v2
markpitchless Apr 18, 2021
6230aeb
Add super linter
markpitchless Apr 18, 2021
5a8c475
Add v2 CHANGELOG
markpitchless Apr 26, 2021
c112604
Review
markpitchless Apr 26, 2021
399af87
Merge pull request #6 from fac/devp/v2
markpitchless Apr 26, 2021
6173353
Update docs for new ruby-gem-setup-credentials-action
markpitchless Apr 26, 2021
28e0146
Merge pull request #7 from fac/devp/setup-v2-docs
markpitchless Apr 26, 2021
4e7c0d2
Version 2.1.0
markpitchless Apr 30, 2021
5da31dd
Merge pull request #8 from fac/devp/v2.1.0
markpitchless Apr 30, 2021
32b2d5a
Version 2.2.0
markpitchless Apr 30, 2021
6fe886e
Merge pull request #9 from fac/devp/fix-pre-release-handling
markpitchless Apr 30, 2021
81f0d56
Explicitly check the push host URL before attempting to push a gem
dgholz May 19, 2021
0798199
Bump changelog
dgholz May 19, 2021
194c5fe
Appease the bash linter
dgholz May 19, 2021
38e2b6d
Merge pull request #10 from fac/dgholz/test_push_host
dgholz May 19, 2021
fd6caf8
Add actionlint (run via Reviewdog)
dgholz Jul 19, 2021
86a8675
Merge pull request #11 from fac/dgholz/add_actionlint
markpitchless Jul 20, 2021
336a829
Support ACTIONS_STEP_DEBUG for debug logging
dgholz Jul 20, 2021
34fd7a2
Send `set -x` output as debug messages
dgholz Jul 20, 2021
26b030b
Update docs to mention how to debug
dgholz Jul 20, 2021
77b8a69
Merge pull request #12 from fac/dgholz/dbg
dgholz Jul 20, 2021
d0d2c8b
Detect when allowed_push_host or GEM_HOST is not set
dgholz Jul 20, 2021
9f71947
Run shellcheck with Reviewdog
dgholz Jul 22, 2021
54b02ae
Add file extension to the bash script
dgholz Jul 22, 2021
b3c0c45
Work around shellcheck's dislike of backticks
dgholz Jul 22, 2021
2f443d3
Merge pull request #13 from fac/dgholz/no_gem_host_no_service
dgholz Aug 2, 2021
2cae2dd
Update README.md
singhprd Sep 22, 2021
fb3610f
Update action.yml
singhprd Apr 28, 2022
61ff978
Update action.yml
singhprd Apr 28, 2022
1a5013c
Update README.md
singhprd Apr 28, 2022
1fb85b2
Switch to the new method of setting outputs
DuncSmith Oct 17, 2022
6abab19
update superlinter
DuncSmith Oct 17, 2022
e0e12e6
bump actionlinter
DuncSmith Oct 17, 2022
9932e82
Merge pull request #16 from fac/github-output-syntax
DuncSmith Oct 18, 2022
02fee17
prepare for v2.5.0
DuncSmith Oct 18, 2022
a936064
Merge pull request #17 from fac/release-2_3
DuncSmith Oct 18, 2022
d63feec
Adding working-directory support to the action
dmorgan-fa Sep 21, 2021
a581d2f
Merge pull request #14 from fac/adding-working-directory-input
odlp Mar 8, 2023
be4308e
Update README.md
dmorgan-fa Mar 13, 2023
dd68309
Use org-wide reusable workflow for actionlint
dmorgan-fa Jun 22, 2023
81d77bf
Merge pull request #18 from fac/org-wide-reusable-actionlint-workflow
dgholz Jun 23, 2023
0713745
Pin GitHub Actions to specific SHAs
DuncSmith Dec 23, 2025
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
rebase-strategy: disabled
open-pull-requests-limit: 10
cooldown:
default-days: 7
11 changes: 11 additions & 0 deletions .github/workflows/check-pinned-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check actions have their versions pinned

on:
push:
paths:
- '.github/workflows/*.yml'
- '.github/workflows/*.yaml'

jobs:
pinact:
uses: fac/shared-workflows/.github/workflows/check_pinned_actions.yml@main
26 changes: 26 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint Code Base
# https://help.github.com/en/articles/workflow-syntax-for-github-actions

on:
pull_request:
push:
branches:
- main

jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.head_ref }}
fetch-depth: 0 # Full history to get a proper list of changed files within `super-linter`

- name: Lint Code Base
uses: github/super-linter@985ef206aaca4d560cb9ee2af2b42ba44adc1d55 # v4.10.0
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_BASH: true
VALIDATE_YAML: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint workflow files

on:
push:
paths:
- '.github/workflows/*.yml'
- '.github/workflows/*.yaml'
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- '.github/workflows/*.yml'
- '.github/workflows/*.yaml'

permissions:
pull-requests: write
contents: read

jobs:
actionlint:
uses: fac/hermod/.github/workflows/actionlint.yml@master
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Shellcheck
on: [pull_request]
jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: shellcheck
uses: reviewdog/action-shellcheck@4c07458293ac342d477251099501a718ae5ef86e # v1.32.0
with:
fail_on_error: true
reporter: github-pr-review
5 changes: 5 additions & 0 deletions .pinact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
version: 3
ignore_actions:
- name: fac/.*
ref: "^(main|master)$"
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
# CHANGELOG

TODO: v2 changes

## [Unreleased]

## [2.5.0] - 2022-10-18

- Update: Switch to the new method of setting outputs (fac/ruby-gem-push-action/pull/16)
- Update: Updated Linters to latest versions

## [2.4.1] - 2021-07-20

- Fix: detect when allowed_push_host or GEM_HOST is not set

## [2.4.0] - 2021-07-20

- Add: support for `ACTIONS_STEP_DEBUG` to see what the push script is doing

## [2.3.0] - 2021-05-19

- Add: explicit preflight check on the push host, to work around gem failing successfully on malformed push hosts

## [2.2.0] - 2021-04-30

- Fix: Bug with pre-release:false input getting ignored

## [2.1.0] - 2021-04-30

- Fix: Bug with pre-release input getting ignored

## [2.0.1] - 2021-04-26

- Update: README to show usage with renamed `ruby-gem-setup-credentials@v2`

## [2.0.0] - 2021-04-26

- Change: Don't pass the gem host around as an environment variable, extract from the gemspec.
- Change: Don't pass gem keys around in environment variables anymore. Use the installed creds by key name.
- Add: input `key` to set the key name in gem credentials to use.
- Change: Release/pre-release inputs collapsed into single pre-release input. Push is either release or pre-release version, can't do both (or none!) in the same call anymore.
- Add: Add linter for action code.
- Change: `tag-release` input renamed to just `tag`.
- Change: Use command line args instead of env variables for the internal command.

## [1.3.0] - 2021-04-16

- Fix: clean shell log handling for `gem push` call

## [1.2.0] - 2021-04-15

- Change: name to ruby-gem-push-action. Old name still works due to GH redirects.

## [1.1.0] - 2021-04-15

- Add: input release: Whether to push release versions
- Add: input pre-release: Whether to push pre-release versions
- Add: input tag-release: After pushing a new gem version, git tag with the version string
- Add: output pushed-version: the version of the gem pushed to the repository

## [1.0.0] - 2021-04-15

- Add basic action that pushes gems to the repository
Expand Down
138 changes: 115 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,158 @@

## Description

Action to push gems to a gem cutter compatible repository. Probably RubyGems or GitHub Package Repository. It expects the authentication to have already been setup, using the environment variables GEM_HOST and GEM_HOST_API_KEY. See [fac/rubygems-setup-gpr-action](https://github.com/fac/rubygems-setup-gpr-action) for an action to set this up for you to push to GPR.
Action to push gems to a gem cutter compatible repository. Basically RubyGems or GitHub Packages. It expects the authentication to have already been setup, `~/.gem/credentials` contains a token for the repo and you know the name of the key.
See [fac/ruby-gem-credentials-action](https://github.com/fac/ruby-gem-setup-credentials-action) for an action to set this up for you. It is actually pretty easy if pushing to the same repo.

If the gem version already exists in the repo the action will no-op and still set a success status. This makes it easier to integrate into workflows, safe to re-run (intentionally of accidentally) and wont push duplicate/replacement packages.
If the gem version already exists in the repo the action will no-op and still set a success status. This makes it easier to integrate into workflows, safe to re-run (intentionally or accidentally) and wont push duplicate/replacement packages.
It will still raise an error visible in the summary, letting you know the version already exists.

## Usage

The action expects that you have already checked out your gem and setup your ruby environment (bundle installed), such that gem and ruby commands are available. The easiest way to do this is using `actions/checkout` and `ruby/setup-ruby` actions with a `.ruby-version` file. See example below.

### Basic Setup

Build and push all new version of the gem:

```yaml
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 # .ruby-version
with:
bundler-cache: true # bundle install

- name: Build Gem
shell: bash
run: bundle exec rake build
- run: bundle exec rake build

- name: Setup GPR
uses: fac/rubygems-setup-gpr-action@v1
- uses: fac/ruby-gem-setup-credentials-action@v2
with:
token: ${{ secrets.github_token }}

- name: Push Gem
uses: fac/rubygems-push-action@v1
- uses: fac/ruby-gem-push-action@v2
with:
key: github
```

If you want to use a different gem host or key:
Note that the ruby-gem-push-action will push to the host given in the gemspec. The token needs to match. Trying to push to a different host will fail.

### Separate release and pre-release workflow

By default, the action only acts on non-pre-release versions, and prints a message if it thinks the gem has a pre-release version number. If you set the input option `pre-release: true`, then it will only act on pre-release versions, and will skip over regular versions. That way, you can have 2 calls to the action, using the workflow to decide the logic.

Say you want to push release versions from your default branch (main) and pre-release versions from PR builds:

```yaml
- name: Push Gem
uses: fac/rubygems-push-action@v1
env:
gem_host: http://gems.example.com
gem_host_api_key: ${{ secrets.EXAMPLE_APYI_KEY }}
name: Gem Build and Release
on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Gem / Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
- name: Test
run: bundle exec rake

release:
name: Gem / Release
needs: test # Only release IF the tests pass
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
- uses: fac/ruby-gem-setup-credentials-action@v2
with:
token: ${{ secrets.github_token }}

- name: Build Gem
run: bundle exec rake build

# Release production gem version from default branch
- name: Release Gem
if: github.ref == 'refs/heads/main'
uses: fac/ruby-gem-push-action@v2
with:
key: github

# PR branch builds will release pre-release gems
- name: Pre-Release Gem
if: github.ref != 'refs/heads/main'
uses: fac/ruby-gem-push-action@v2
with:
key: github
pre-release: true
```

Here we run the test on its own job, so that it gets it's own status on the PR, that you can require separately from the release job in your branch protection.
The release job runs if the tests pass, we always package the gem to test that works. For release we use a conditional along with the actions inputs to push release versions for the main branch only and push pre-releases for PR.

### Debugging

This action supports [debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging). Enable it by setting the `ACTIONS_STEP_DEBUG` secret to `true` on your repository.

## Inputs

### package-glob
### working-directory
Sets the working directory before all other steps occur. This is useful for cases where files like `.ruby-version` and `Gemfile` aren't located in the root directory. For example in a monorepo where the Ruby project is located in its own subfolder.

```yaml
name: Push Gem
uses: fac/ruby-gem-push-action@v2
with:
working-directory: './ruby_project/'
```

### gem-glob

File glob to match the gem file to push. The default `pkg/*.gem` picks up gems built using `bundle exec rake build`. You may need to set this if your your gem builds another way.
_Note_: `working-directory` is set before this step, therefore if both inputs are provided, this path will be relative to the `working-directory`.

```yaml
- name: Push Gem
uses: fac/rubygems-push-action@v1
uses: fac/ruby-gem-push-action@v2
with:
package-glob: build/special.gem
gem-glob: build/special.gem
```
### pre-release

Whether to push new pre-release versions of the gem and ignore releases, instead of the normal, push prod releases but ignore pre-release.

### tag

When true (the default), after pushing a new gem version tag the repo with
the version number prefixed with `v`. e.g. after pushing version `0.1.0`, the
tag will be `v0.1.0`. This is the same behavior as `gem tag`. (Internally
implemented to work with older gem versions and around bugs that caused tags for failed pushes, which then blocked re-pushing.

The tag commit and push will be made as the author of the commit being tagged.

## Outputs

None.
### pushed-version

If we pushed a gem to the repository, this will be set to the version pushed.

## Environment Variables

### GEM_HOST_API_KEY
None.

Read to get the API key string (prefixed token with Bearer), to access the package repo. Used by `gem push`.
## Troubleshooting

### GEM_HOST
If when tagging the action fails with `shallow update not allowed` try setting `fetch-depth` to 0, i.e. dont' do a shallow clone.

```yml
- uses: actions/checkout@v2
with:
fetch-depth: 0
```

The host URL for pushing gems to.

## Authors

Expand Down
Loading
Loading