Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smoonlee/dbf62fc49db565663ac4946ddaeb3bfd to your computer and use it in GitHub Desktop.
Save smoonlee/dbf62fc49db565663ac4946ddaeb3bfd to your computer and use it in GitHub Desktop.
name: Test Code - Version Check
on:
workflow_dispatch
jobs:
Job:
name: Checkout code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Package Version
id: package_version
run: |
package_name="github-docker"
response=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.PatToken }}" "https://api.github.com/user/packages/container/$package_name/versions")
tag_version=$(echo "$response" | jq -r '.[0].metadata.container.tags[0]')
# Increment the version manually
IFS='.' read -ra version_parts <<< "$tag_version"
patch=$((version_parts[2] + 1))
next_version="${version_parts[0]}.${version_parts[1]}.$patch"
echo "CURRENT_VERSION=$tag_version" >> $GITHUB_ENV
echo "UPDATED_VERSION=$next_version" >> $GITHUB_ENV
- name: Display Package Version
run: |
echo "Current version: $CURRENT_VERSION"
echo "Next Release : $UPDATED_VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment