Skip to content

Commit eea3233

Browse files
ashleywillardmartinemdehellosweta
authored
combine tag and release actions (#18)
Co-authored-by: Martin Emde <[email protected]> Co-authored-by: Sweta Sanghavi <[email protected]>
1 parent 6bdea6b commit eea3233

File tree

2 files changed

+49
-63
lines changed

2 files changed

+49
-63
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,58 @@
1-
name: Release Gem
1+
name: Tag and Release Gem
2+
3+
env:
4+
GEM_NAME: query_packwerk
5+
GEM_CLASS_NAME: QueryPackwerk
26

37
on:
4-
push:
5-
tags:
6-
- v*
8+
pull_request:
9+
types: [closed]
10+
branches: [main]
711

812
permissions:
9-
contents: read
13+
contents: write
14+
actions: read
1015

1116
jobs:
12-
push:
13-
if: |
14-
github.event.workflow_run.conclusion == 'success' &&
15-
github.repository == 'rubyatscale/query_packwerk' &&
16-
startsWith(github.ref, 'refs/tags/v')
17+
tag:
18+
if: github.event.pull_request.merged == true
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Ruby
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: 3.2
27+
28+
- name: Determine release type
29+
id: version
30+
run: |
31+
if [[ "${{ github.event.pull_request.labels[*] }}" == *"major"* ]]; then
32+
echo "bump=major" >> $GITHUB_OUTPUT
33+
elif [[ "${{ github.event.pull_request.labels[*] }}" == *"minor"* ]]; then
34+
echo "bump=minor" >> $GITHUB_OUTPUT
35+
else
36+
echo "bump=patch" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Bump version
40+
run: |
41+
gem install bump
42+
bump ${{ steps.version.outputs.bump }}
43+
44+
- name: Commit and tag version bump
45+
run: |
46+
# Attribute commits to the last committer on HEAD
47+
git config --global user.email "$(git log -1 --pretty=format:'%ae')"
48+
git config --global user.name "$(git log -1 --pretty=format:'%an')"
49+
git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY"
50+
VERSION=$(ruby -e "require './lib/${{ env.GEM_NAME }}/version'; puts ${{ env.GEM_CLASS_NAME }}::VERSION")
51+
git commit -am "Bump version to $VERSION"
52+
git tag "v$VERSION"
53+
git push origin main "v$VERSION"
54+
release:
55+
if: github.repository == 'rubyatscale/query_packwerk'
1756
runs-on: ubuntu-latest
1857
environment: release
1958
permissions:

.github/workflows/tag.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)