You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+83-1Lines changed: 83 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,15 @@ If the gem version already exists in the repo the action will no-op and still se
8
8
9
9
## Usage
10
10
11
+
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 availiable. The easiest way to do this is using `actions/checkout` and `ruby/setup-ruby` actions with a `.ruby-version` file. See example below.
12
+
13
+
### Basic Setup
14
+
15
+
Build and push all new version of the gem:
16
+
11
17
```yaml
12
18
steps:
19
+
# Setup ruby environment
13
20
- uses: actions/checkout@v2
14
21
- uses: ruby/setup-ruby@v1 # .ruby-version
15
22
@@ -36,6 +43,62 @@ If you want to use a different gem host or key:
36
43
gem_host_api_key: ${{ secrets.EXAMPLE_APYI_KEY }}
37
44
```
38
45
46
+
### Separate release and pre-release workflow
47
+
48
+
You probably don't want to push all versions from any branch. More likely you would want to push release versions from your default branch (e.g. main) and pre-release from PR builds. To help with this the release and pre-release inputs can be used:
49
+
50
+
```yaml
51
+
name: Gem Build and Release
52
+
on:
53
+
push:
54
+
branches:
55
+
- main
56
+
pull_request:
57
+
58
+
jobs:
59
+
test:
60
+
name: Gem / Test
61
+
runs-on: ubuntu-latest
62
+
steps:
63
+
- uses: actions/checkout@v2
64
+
- uses: ruby/setup-ruby@v1
65
+
- name: Test
66
+
run: bundle exec rake
67
+
68
+
release:
69
+
name: Gem / Release
70
+
needs: test
71
+
runs-on: ubuntu-latest
72
+
73
+
steps:
74
+
- uses: actions/checkout@v2
75
+
- uses: ruby/setup-ruby@v1
76
+
77
+
- name: Build Gem
78
+
run: bundle exec rake build
79
+
80
+
- name: Setup GPR
81
+
uses: fac/rubygems-setup-gpr-action@v1
82
+
with:
83
+
token: ${{ secrets.github_token }}
84
+
85
+
# Release production gem version from default branch
86
+
- name: Push Release Gem
87
+
if: github.ref == 'refs/heads/main'
88
+
uses: fac/rubygems-push-action@v1
89
+
90
+
# PR branch builds will release pre-release gems
91
+
- name: Push Pre-Release Gem
92
+
if: github.ref != 'refs/heads/main'
93
+
uses: fac/rubygems-push-action@v1
94
+
with:
95
+
release: false
96
+
pre-release: true
97
+
```
98
+
99
+
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.
100
+
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.
101
+
39
102
## Inputs
40
103
41
104
### package-glob
@@ -49,9 +112,28 @@ File glob to match the gem file to push. The default `pkg/*.gem` picks up gems b
49
112
package-glob: build/special.gem
50
113
```
51
114
115
+
### release
116
+
117
+
Whether to push new release versions of the gem. Defaults to true.
118
+
119
+
### pre-release
120
+
121
+
Whether to push new pre-release versions of the gem. Defaults to true.
122
+
123
+
### tag-release
124
+
125
+
When true (the default), after pushing a new gem version tag the repo with
126
+
the version number prefixed with `v`. e.g. after pushing version `0.1.0`, the
127
+
tag will be `v0.1.0`. This is the same behavior as `gem tag`, but internally
128
+
implemented to work with older gem versions.
129
+
130
+
The tag commit and push will be made as the author of the commit being tagged.
131
+
52
132
## Outputs
53
133
54
-
None.
134
+
### pushed-version
135
+
136
+
If we pushed a gem to the repository, this will be set to the version pushed.
0 commit comments