Skip to content

Commit

Permalink
fix: get latest tag
Browse files Browse the repository at this point in the history
Signed-off-by: dwertent <[email protected]>
  • Loading branch information
dwertent committed Sep 6, 2024
1 parent 4f64fd9 commit 7705629
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
35 changes: 12 additions & 23 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,25 @@ on:
types: [released, prereleased]

jobs:
fetch-latest-tag:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.get_latest_tag.outputs.latest_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --tags

- name: Get the latest tag
id: get_latest_tag
run: |
latest_tag=$(git tag -l | sort -V | tail -n 1)
echo "::set-output name=latest_tag::${latest_tag}"

docker:
runs-on: ubuntu-latest
needs: fetch-latest-tag
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get the latest tag
id: get_latest_tag
run: |
git fetch --tags
latest_tag=$(git tag -l | sort -V | tail -n 1)
echo "latest tag: $latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -48,9 +37,9 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set latest tag
if: github.event.action == 'released' && github.ref_name == needs.fetch-latest-tag.outputs.latest_tag
if: github.event.action == 'released' && github.ref_name == env.LATEST_TAG
run: |
echo "DOCKER_TAGS=${{ env.DOCKER_TAGS }},ghcr.io/${{ github.repository }}:latest" >> $GITHUB_ENV
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,24 @@ jobs:
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Check if this is the latest release
- name: Get the latest tag
run: |
LATEST_TAG=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name'
)
IS_LATEST=${{ $LATEST_TAG == github.event.release.tag_name }}
echo This release is: "${{ github.event.release.tag_name }}"
echo The latest release is: "$LATEST_TAG"
echo "IS_LATEST_RELEASE=$IS_LATEST" >> "$GITHUB_ENV"
git fetch --tags
latest_tag=$(git tag -l | sort -V | tail -n 1)
echo "latest tag: $latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Install docs dependencies
working-directory: doc-site
run: pip install -r requirements.txt

- name: Update doc site for release
if: ${{ github.event_name == 'release' && env.IS_LATEST_RELEASE != 'true' }}
if: github.event.action == 'released' && github.ref_name == env.LATEST_TAG
working-directory: doc-site
run: mike deploy ${{ github.event.release.tag_name }} --push

- name: Update doc site for latest release
if: ${{ github.event_name == 'release' && env.IS_LATEST_RELEASE == 'true' }}
if: github.event.action == 'released' && github.ref_name == env.LATEST_TAG
working-directory: doc-site
run: mike deploy ${{ github.event.release.tag_name }} latest -u --push

Expand Down

0 comments on commit 7705629

Please sign in to comment.