Skip to content

Merge branch 'actions-test' of github.com:ppooll-dev/ppooll into acti… #42

Merge branch 'actions-test' of github.com:ppooll-dev/ppooll into acti…

Merge branch 'actions-test' of github.com:ppooll-dev/ppooll into acti… #42

Workflow file for this run

name: Automate Versioning and Release
on:
push:
branches:
# - main
- actions-test
jobs:
release:
runs-on: ubuntu-latest
# This line will prevent the job from running if the commit message is "Bump version"
if: "!contains(github.event.head_commit.message, 'Bump version')"
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.MACHINE_USER_PAT }}
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Bump version using Bash
run: |
# Extract base_version from the JSON
BASE_VERSION=$(jq -r '.base_version' package-info.json)
# Get today's date in the format YYMMDD
DATE=$(date -u +"%y%m%d")
# Extract the date and count from the version key
VERSION_DATE=$(jq -r '.version' package-info.json | cut -d'.' -f4)
VERSION_COUNT=$(jq -r '.version' package-info.json | cut -d'.' -f5)
# Determine the count
if [[ $DATE -gt $VERSION_DATE ]]; then
COUNT=1
else
COUNT=$((VERSION_COUNT+1))
fi
# Construct the new version
NEW_VERSION="${BASE_VERSION}.${DATE}.${COUNT}"
# Update the version in the JSON using jq
jq --arg v "$NEW_VERSION" '.version = $v' package-info.json > temp.json && mv temp.json package-info.json
# Extract the updated version
VERSION=$(jq -r '.version' package-info.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Commit updated package-info.json
run: |
git config user.name "ppooll-machine"
git config user.email "[email protected]"
git add package-info.json
git commit -m "Bump version"
git remote set-url origin https://machine_user_name:${{ secrets.MACHINE_USER_PAT }}@github.com/ppooll-dev/ppooll.git
git push origin actions-test
- name: Create ZIP Archive
run: |
# Create a temporary directory called 'ppooll'
mkdir ppooll
# Copy all repository files into 'ppooll' directory
rsync -av --progress --exclude=ppooll . ppooll/
# Create a ZIP archive
zip -r ppooll.zip ppooll/
- name: Install GitHub CLI
run: |
curl -sSL https://github.com/cli/cli/releases/download/v2.3.0/gh_2.3.0_linux_amd64.tar.gz | tar xz -C /tmp
sudo mv /tmp/gh_2.3.0_linux_amd64/bin/gh /usr/local/bin/
gh --version
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $VERSION ppooll.zip --title "$VERSION" --notes "Automated release for $VERSION"