Skip to content

Commit

Permalink
Added Github Action to release & Publish gem
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-pickin-epi committed Nov 24, 2023
1 parent 452f864 commit 01e07a6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release and Publish Gem
on:
workflow_dispatch: {}

jobs:
build:
name: "Build gem package"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Git Information"
id: gitinfo
run: |
echo name=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
echo branch=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT
make tags >> $GITHUB_OUTPUT
- name: "Publish gem"
env:
VERSION: ${{ steps.gitinfo.outputs.tag }}
shell: "bash"
run: "make publish"

- name: "Create Release"
id: release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ steps.gitinfo.outputs.tag }}
body: ${{steps.github_release.outputs.changelog}}
draft: false
prerelease: false
files: |
lr_common_styles-${{ steps.gitinfo.outputs.version }}.gem
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
.PHONY: auth clean gem publish test
.PHONY: clean gem publish test

NAME?=lr_common_styles
OWNER?=epimorphics
VERSION?=$(shell ruby -e 'require "./lib/lr_common_styles/version" ; puts LrCommonStyles::VERSION')
PAT?=$(shell read -p 'Github access token:' TOKEN; echo $$TOKEN)

AUTH=${HOME}/.gem/credentials
GEM=${NAME}-${VERSION}.gem
GPR=https://rubygems.pkg.github.com/${OWNER}
SPEC=${NAME}.gemspec

all: publish

${AUTH}:
@mkdir -p ${HOME}/.gem
@echo '---' > ${AUTH}
@echo ':github: Bearer ${PAT}' >> ${AUTH}
@chmod 0600 ${AUTH}

${GEM}: ${SPEC} ./lib/lr_common_styles/version.rb
gem build ${SPEC}

auth: ${AUTH}

build: gem

gem: ${GEM}
Expand All @@ -40,5 +31,5 @@ publish: ${GEM}
clean:
@rm -rf ${GEM}

realclean: clean
@rm -rf ${AUTH}
tags:
@echo version=${VERSION}

0 comments on commit 01e07a6

Please sign in to comment.