Bump version #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automate Versioning and Release | |
on: | |
push: | |
branches: | |
# - main | |
- actions-test | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
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 | |
# Display the new version | |
cat package-info.json | |
- name: Commit updated package-info.json | |
run: | | |
git config user.name "ppooll-machine" | |
git config user.email "ppoollmachine@gmail.com" | |
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: | | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 | |
sudo apt-add-repository https://cli.github.com/packages | |
sudo apt update | |
sudo apt install gh | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create auto-$DATE-release ppooll.zip --title "Automatic Release $DATE" --notes "Automated release for $DATE" |