Skip to content

Commit 360aab4

Browse files
committed
Add gem-push workflow
1 parent ca2672f commit 360aab4

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

.github/scripts/check-release.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Checking if current tag matches the package version.
4+
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | sed -r 's/^v//')
5+
file_tag=$(grep 'VERSION = ' lib/tahweel/version.rb | cut -d '=' -f 2- | tr -d ' ' | tr -d \')
6+
if [ "$current_tag" != "$file_tag" ]; then
7+
echo "Error: the current tag does not match the version in package file(s)."
8+
echo "$current_tag vs $file_tag"
9+
exit 1
10+
fi
11+
12+
echo 'OK'
13+
exit 0

.github/workflows/gem-push.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release Gem to RubyGems.org
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-publish:
9+
name: Build and Publish Package to RubyGems.org
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
- name: Set up Ruby 3.4.7
16+
uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: 3.4.7
19+
bundler-cache: true
20+
- name: Check release validity
21+
run: sh .github/scripts/check-release.sh
22+
- name: Publish to RubyGems
23+
env:
24+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
25+
run: |
26+
mkdir -p $HOME/.gem
27+
touch $HOME/.gem/credentials
28+
chmod 0600 $HOME/.gem/credentials
29+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
30+
gem build tahweel.gemspec
31+
gem push *.gem

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
DEBIAN_FRONTEND: noninteractive
2525
run:
2626
sudo apt-get install --fix-missing -qq -o Acquire::Retries=3 libvips
27-
- uses: actions/checkout@v4
27+
- name: Checkout code
28+
uses: actions/checkout@v4
2829
with:
2930
persist-credentials: false
3031
- name: Set up Ruby

0 commit comments

Comments
 (0)