-
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.
Update workflow to trigger on all branches
- Loading branch information
Daniel Granerud
committed
May 28, 2020
1 parent
f22d094
commit 7cf35e2
Showing
1 changed file
with
96 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,105 @@ | ||
name: Ruby Gem | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: [ master ] | ||
on: [pull_request, push] | ||
|
||
jobs: | ||
build: | ||
name: Build, Test and Publish Ruby Gem | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Fetch all history for all tags and branches | ||
run: | | ||
git fetch --prune --unshallow --tags | ||
echo "REF: ${{ github.ref }}" | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: '5.2.x' | ||
|
||
- name: Execute GitVersion | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
||
- name: Version variables for unstable builds | ||
id: unstable | ||
if: startsWith(github.ref, 'refs/tags/') != true | ||
env: | ||
LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} | ||
run: | | ||
echo "Pre-release: ${LABEL}" | ||
echo "::set-output name=label::${LABEL}" | ||
- name: Create gem version number | ||
id: gemversion | ||
env: | ||
GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" | ||
run: | | ||
echo "Gem version: ${GEM_VERSION}" | ||
echo "::set-output name=version::${GEM_VERSION}" | ||
- name: Set up Ruby 2.6 | ||
uses: actions/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6.x | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: ${{ runner.os }}-gems- | ||
|
||
- name: Bundle install | ||
run: | | ||
gem install bundler | ||
bundle config path vendor/bundle | ||
bundle install --jobs 4 --retry 3 | ||
- name: Build gem | ||
id: gem | ||
env: | ||
GEM_VERSION: ${{ steps.gemversion.outputs.version }} | ||
run: | | ||
GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') | ||
echo "Gem filename: '${GEM_BUILD_NAME}'" | ||
echo "::set-output name=name::${GEM_BUILD_NAME}" | ||
- name: Test gem | ||
run: | | ||
bundle exec rake test | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2-preview | ||
with: | ||
name: ${{ steps.gem.outputs.name }} | ||
path: ${{ steps.gem.outputs.name }} | ||
|
||
- name: Publish to GPR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: SwedbankPay | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials | ||
set -e | ||
gem push --KEY github \ | ||
--host https://rubygems.pkg.github.com/${OWNER} \ | ||
${{ steps.gem.outputs.name }} \ | ||
|| echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." | ||
- name: Publish to RubyGems | ||
if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits | ||
env: | ||
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials | ||
gem push ${{ steps.gem.outputs.name }} | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Fetch all history for all tags and branches | ||
run: | | ||
git fetch --prune --unshallow --tags | ||
echo "REF: ${{ github.ref }}" | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: "5.2.x" | ||
|
||
- name: Execute GitVersion | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
||
- name: Version variables for unstable builds | ||
id: unstable | ||
if: startsWith(github.ref, 'refs/tags/') != true | ||
env: | ||
LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} | ||
run: | | ||
echo "Pre-release: ${LABEL}" | ||
echo "::set-output name=label::${LABEL}" | ||
- name: Create gem version number | ||
id: gemversion | ||
env: | ||
GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" | ||
run: | | ||
echo "Gem version: ${GEM_VERSION}" | ||
echo "::set-output name=version::${GEM_VERSION}" | ||
- name: Set up Ruby 2.6 | ||
uses: actions/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6.x | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: ${{ runner.os }}-gems- | ||
|
||
- name: Bundle install | ||
run: | | ||
gem install bundler | ||
bundle config path vendor/bundle | ||
bundle install --jobs 4 --retry 3 | ||
- name: Build gem | ||
id: gem | ||
env: | ||
GEM_VERSION: ${{ steps.gemversion.outputs.version }} | ||
run: | | ||
GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') | ||
echo "Gem filename: '${GEM_BUILD_NAME}'" | ||
echo "::set-output name=name::${GEM_BUILD_NAME}" | ||
- name: Test gem | ||
run: | | ||
bundle exec rake test | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2-preview | ||
with: | ||
name: ${{ steps.gem.outputs.name }} | ||
path: ${{ steps.gem.outputs.name }} | ||
|
||
- name: Publish to GPR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: SwedbankPay | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials | ||
set -e | ||
gem push --KEY github \ | ||
--host https://rubygems.pkg.github.com/${OWNER} \ | ||
${{ steps.gem.outputs.name }} \ | ||
|| echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." | ||
- name: Publish to RubyGems | ||
if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits | ||
env: | ||
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials | ||
gem push ${{ steps.gem.outputs.name }} |