Skip to content

Commit

Permalink
ci.yml: Prerelease versions use number of deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeGat committed Nov 14, 2024
1 parent 0deb92c commit 00fa254
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,19 @@ jobs:
# This step generates the release and prerelease version numbers.
# The release is a general version number from the spack.yaml, looking the
# same as a regular release build. Ex. 'access-om2@git.2024.01.1' -> '2024.01.1'
# The prerelease looks like: `pr<pull request number>-<number of commits on this branch>`.
# Ex. Pull Request #12 with 2 commits on branch -> `pr12-2`.
# The prerelease looks like: `pr<pull request number>-<number of deployments of pull request>`.
# Ex. Pull Request #12 with 2 deployments on branch -> `pr12-2`.
run: |
echo "release=$(yq '${{ env.SPACK_YAML_MODEL_YQ }} | split("@git.") | .[1]' spack.yaml)" >> $GITHUB_OUTPUT
number_of_commits=$(git rev-list --count ${{ github.event.pull_request.base.sha }}..HEAD)
echo "prerelease=pr${{ github.event.pull_request.number }}-${number_of_commits}" >> $GITHUB_OUTPUT
# Essentially, count all the deployment entries that match the given branch.
# See https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#list-deployments
next_deployment_number=$(gh api \
-H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/deployments \
--jq '[.[] | select(.ref == '${{ github.ref_name }}')] | length + 1'
)
echo "prerelease=pr${{ github.event.pull_request.number }}-${next_deployment_number}" >> $GITHUB_OUTPUT
# -----------------------------
# | PRERELEASE DEPLOYMENT JOB |
Expand Down

0 comments on commit 00fa254

Please sign in to comment.