-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fac/devp/v1.1.0
Devp/v1.1.0 See: fac/dev-platform#62
- Loading branch information
Showing
5 changed files
with
192 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
# See: https://docs.github.com/en/actions/creating-actions | ||
name: Gem Push | ||
author: FreeAgent | ||
description: Push gem packages to a rubygems compatible repo | ||
description: Push gem packages to a rubygems compatible repository | ||
inputs: | ||
package-glob: | ||
description: "File glob to match the .gem files to push" | ||
description: File glob to match the .gem files to push | ||
default: "pkg/*.gem" | ||
release: | ||
description: Whether to push release versions | ||
default: true | ||
pre-release: | ||
description: Whether to push pre-release versions | ||
default: true | ||
tag-release: | ||
description: After pushing a new gem version, git tag with the version string | ||
default: true | ||
outputs: | ||
pushed-version: | ||
description: "The version of the gem pushed to the repository" | ||
value: ${{ steps.push-gem.outputs.pushed-version }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Push Gem | ||
id: push-gem | ||
shell: bash | ||
env: | ||
# Expects GEM_HOST and GEM_HOST_API_KEY to be set | ||
GEM_GLOB: ${{ inputs.package-glob }} | ||
INPUT_PACKAGE_GLOB: ${{ inputs.package-glob }} | ||
INPUT_RELEASE: ${{ inputs.release }} | ||
INPUT_PRE_RELEASE: ${{ inputs.pre-release }} | ||
INPUT_TAG_RELEASE: ${{ inputs.tag-release }} | ||
run: | | ||
if ! gem push --host "$GEM_HOST" $GEM_GLOB | tee push.out; then | ||
gemerr=$? | ||
if grep "has already been pushed" push.out; then | ||
echo Gem Already Pushed | ||
exit 0 | ||
fi | ||
echo ::error::Gem Push Failed | ||
cat push.out | sed 's/^/::error::/' | ||
exit $gemerr | ||
fi | ||
exit 0 | ||
PATH="${{ github.action_path }}:$PATH" | ||
gem-push-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/bash | ||
set -e -o pipefail | ||
|
||
if parse-gemspec --is-pre-release; then | ||
if [[ $INPUT_PRE_RELEASE != true ]]; then | ||
echo "Ignoring pre-release. To release, pass pre-release: true as an input" | ||
exit 0 | ||
fi | ||
elif [[ $INPUT_RELEASE != true ]]; then | ||
echo "Ignoring release. To release, pass release: true as an input" | ||
exit 0 | ||
fi | ||
|
||
# tee the output to get it in the logs but capture as we can't tell why gem | ||
# push failed from the exit code, so need to grep the output. Gem existing is | ||
# ok, other errors not. Avoids playing games setting up auth differently for | ||
# gem query. | ||
# Note: the glob is intentially unquoted, we want a glob! | ||
if ! gem push --host "$GEM_HOST" $INPUT_PACKAGE_GLOB | tee push.out; then | ||
gemerr=$? | ||
if grep -q "has already been pushed" push.out; then | ||
echo Gem Already Pushed | ||
exit 0 | ||
fi | ||
echo ::error::Gem Push Failed | ||
sed 's/^/::error::/' push.out | ||
exit $gemerr | ||
fi | ||
|
||
echo "::set-output name=pushed-version::$( parse-gemspec --version )" | ||
|
||
if [[ $INPUT_TAG_RELEASE == true ]]; then | ||
tagname="v$( parse-gemspec --version )" | ||
git config user.name "$(git log -1 --pretty=format:%an)" | ||
git config user.email "$(git log -1 --pretty=format:%ae)" | ||
git tag -a -m "Gem release $tagname" "$tagname" | ||
git push origin "$tagname" | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'optparse' | ||
|
||
gemspecs = Dir["*.gemspec"] | ||
|
||
if gemspecs.empty? | ||
warn "No gemspec found" | ||
exit 10 | ||
end | ||
|
||
if gemspecs.count > 1 | ||
warn "More than one gemspec found" | ||
exit 10 | ||
end | ||
|
||
spec = Gem::Specification.load(gemspecs.first) | ||
exit 10 unless spec | ||
|
||
def puts!(msg) | ||
puts msg | ||
exit | ||
end | ||
|
||
OptionParser.new do |opts| | ||
opts.banner = "Usage: #{File.basename($0)} [options]" | ||
opts.on("-h", "--help", "Prints this help") do | ||
puts! opts | ||
end | ||
opts.on("--name", "Output gemspec name") do |v| | ||
puts! spec.name | ||
end | ||
opts.on("--version", "Output gemspec gem version") do |v| | ||
puts! spec.version | ||
end | ||
opts.on("--is-pre-release", "Exit 0 if pre-release, 1 otherwise") do |v| | ||
exit 0 if spec.version.prerelease? | ||
exit 1 | ||
end | ||
end.parse! |