Manual Release #4
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: Manual Release | |
on: | |
workflow_dispatch: # This allows the workflow to be run manually | |
jobs: | |
release: # create a nightly 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 | |
# 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 main | |
- 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 "Manual release for $VERSION" | |
- name: Notify Discord | |
run: | | |
# Get the URL of the latest release | |
RELEASE_URL="https://github.com/$GITHUB_REPOSITORY/releases/latest" | |
# Construct the content for the Discord message | |
CONTENT="There's a new release! Check out version $VERSION [here]($RELEASE_URL)." | |
# Send a POST request to the Discord webhook | |
curl -H "Content-Type: application/json" \ | |
-X POST \ | |
-d "{\"content\": \"$CONTENT\"}" \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |