Skip to content

Commit 96e9d9a

Browse files
authored
Merge pull request #73 from messagebird/release_publish_actions
Add release and publish GitHub actions
2 parents b36e471 + 8e3c4c1 commit 96e9d9a

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: RubyGems release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
14+
- name: Publish gem
15+
uses: dawidd6/action-publish-gem@v1
16+
with:
17+
api_key: ${{secrets.RUBYGEMS_API_KEY}}

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [ labeled ]
6+
branches:
7+
- master
8+
9+
jobs:
10+
prepare-release:
11+
name: Prepare release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set major release
16+
if: ${{ github.event.label.name == 'release-major' }}
17+
run: echo "RELEASE=major" >> $GITHUB_ENV
18+
- name: Set minor release
19+
if: ${{ github.event.label.name == 'release-minor' }}
20+
run: echo "RELEASE=minor" >> $GITHUB_ENV
21+
- name: Set patch release
22+
if: ${{ github.event.label.name == 'release-patch' }}
23+
run: echo "RELEASE=patch" >> $GITHUB_ENV
24+
- name: Check release env
25+
run: |
26+
if [[ -z "${{ env.RELEASE }}" ]];
27+
then
28+
echo "You need to set a release label on PRs to the main branch"
29+
exit 1
30+
else
31+
exit 0
32+
fi
33+
- name: Install semver-tool
34+
run: |
35+
export DIR=$(mktemp -d)
36+
cd $DIR
37+
curl https://github.com/fsaintjacques/semver-tool/archive/3.2.0.tar.gz -L -o semver.tar.gz
38+
tar -xvf semver.tar.gz
39+
sudo cp semver-tool-3.2.0/src/semver /usr/local/bin
40+
- name: Bump version
41+
run: |
42+
export CURRENT=$(gem info messagebird-rest --remote --exact | grep -o "messagebird-rest ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
43+
export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
44+
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
45+
- name: Checkout code
46+
uses: actions/checkout@v2
47+
- name: Setup git
48+
run: |
49+
git config user.email "[email protected]"
50+
git config user.name "MessageBird CI"
51+
git fetch
52+
git checkout ${{ github.event.pull_request.head.ref }}
53+
- name: Prepare version.rb
54+
run: |
55+
sed -i "s|STRING = '[^']*'|STRING = '${{ env.VERSION }}'|" lib/messagebird/version.rb
56+
- name: Commit changes
57+
run: |
58+
git add lib/messagebird/version.rb
59+
git commit -m "Bump to version ${{ env.VERSION }}"
60+
- name: Push
61+
run: git push

.github/workflows/ruby_ci.yml renamed to .github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: Ruby CI
1+
name: Tests
22

3-
on: [ push, pull_request ]
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master, main]
47

58
jobs:
69
ci:

lib/messagebird/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module MessageBird
44
module Version
5-
STRING = '3.0.0'
5+
STRING = '3.1.0'
66
end
77
end

0 commit comments

Comments
 (0)