Skip to content

Commit

Permalink
Redesigned Github actions so PR's will have a required version check …
Browse files Browse the repository at this point in the history
…action before it can be merged
  • Loading branch information
AllRWeak authored and bl0way committed Jul 10, 2024
1 parent 208f97c commit 0493ef0
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 69 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Creating new tag & release

on:
push:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tag_and_release:
runs-on: ubuntu-latest

steps:
- name: Cloning the repository repo...
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Creating a tag and a release
run: |
VERSION_FILE="nova/core/galaxy.yml"
VERSION=$(cat $VERSION_FILE | grep "version:" | cut -d " " -f 2)
TAG_NAME="v$VERSION"
echo "LATEST_TAG=$TAG_NAME" >> $GITHUB_ENV
# Tagging and pushing the change
git tag $TAG_NAME
git push origin $TAG_NAME
# Creating temp changelog file
git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^^)..HEAD > CHANGELOG.md
- name: Releasing a new version...
uses: ncipollo/release-action@v1
with:
tag: ${{ env.LATEST_TAG }}
bodyFile: CHANGELOG.md
68 changes: 0 additions & 68 deletions .github/workflows/version.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Comparing PR version with the latest version

on:
pull_request:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
version_check:
runs-on: ubuntu-latest

steps:
- name: Cloning the repository pull request repo...
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Comparing PR version with main...
run: |
export C_RED="\x1b[91m"
export C_GREEN="\x1b[92m"
export C_YELLOW="\x1b[93m"
export C_RST="\x1b[0m"
VERSION_FILE="nova/core/galaxy.yml"
REMOTE_VERSION_URL="${{ vars.PROJECT_VERSION_FILE_URL }}"
PR_VERSION=$(cat $VERSION_FILE | grep "version:" | cut -d " " -f 2)
CURRENT_VERSION=$(curl "$REMOTE_VERSION_URL" -s | grep "version:" | cut -d " " -f 2)
echo -n -e "${C_YELLOW}"
echo -e "Pull Request Version - $PR_VERSION"
echo -e "Current Version - $CURRENT_VERSION"
echo -n -e "${C_RST}"
if [[ $(echo "$PR_VERSION" | tr -d '.') -le $(echo "$CURRENT_VERSION" | tr -d '.') ]]; then
echo -n -e "${C_RED}"
echo -e "Pull request version $PR_VERSION is <= than current version $CURRENT_VERSION."
echo -e "Please update the version in $VERSION_FILE file."
echo -n -e "${C_RST}"
exit 1
else
echo -n -e "${C_GREEN}"
echo "Version has been updated moving on"
echo -n -e "${C_RST}"
fi
2 changes: 1 addition & 1 deletion nova/core/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace: nova
name: core

# The version of the collection. Must be compatible with semantic versioning
version: 3.0.2
version: 3.0.5

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down

0 comments on commit 0493ef0

Please sign in to comment.