Skip to content

Commit

Permalink
ci: 👷 add main branch to ci; compare dev/prod tags when bumping versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xminent committed Dec 11, 2023
1 parent b120762 commit a960d58
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
branches:
- main
- dev
paths:
- "**ci.yml"
Expand All @@ -11,13 +12,18 @@ on:
- "**CMakeLists.txt"
pull_request:
branches:
- main
- dev
paths:
- "**ci.yml"
- "**.hpp"
- "**.cpp"
- "**CMakeLists.txt"

env:
PRERELEASE: ${{ github.ref == 'refs/heads/dev' && 'true' || 'false' }}
TAG_SUFFIX: ${{ github.ref == 'refs/heads/dev' && '-dev' || '' }}

jobs:
build:
strategy:
Expand Down Expand Up @@ -101,21 +107,34 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Get Latest Tag
id: latest-tag
run: |
if [[ ${{ github.ref }} == 'refs/heads/dev' ]]; then
latest_tag=$(git tag -l | grep "\-dev" | sort -V | tail -n 1)
else
latest_tag=$(git tag -l | grep -v "\-dev" | sort -V | tail -n 1)
fi
echo "::set-output name=tag::$latest_tag"
shell: bash

- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: dev
branch: ${{ github.ref == 'refs/heads/dev' && 'dev' || 'main' }}
fromTag: ${{ steps.latest-tag.outputs.tag }}

- name: Create Draft Release
uses: ncipollo/[email protected]
with:
prerelease: true
prerelease: ${{ env.PRERELEASE }}
draft: false
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.next }}-dev
name: ${{ steps.semver.outputs.next }}-dev
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
name: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
body: "*pending*"
token: ${{ github.token }}

Expand All @@ -124,19 +143,19 @@ jobs:
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ steps.semver.outputs.next }}-dev
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
writeToFile: false

- name: Create Release
uses: ncipollo/[email protected]
with:
prerelease: true
prerelease: ${{ env.PRERELEASE }}
allowUpdates: true
draft: false
makeLatest: true
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.next }}-dev
name: ${{ steps.semver.outputs.next }}-dev
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
name: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}

Expand All @@ -160,4 +179,4 @@ jobs:
repo_token: ${{ github.token }}
file_glob: true
file: "**/*"
tag: ${{ needs.release.outputs.next }}-dev
tag: ${{ needs.release.outputs.next }}${{ env.TAG_SUFFIX }}

0 comments on commit a960d58

Please sign in to comment.