Skip to content

Commit

Permalink
ci.yml: Added tagging logic to before prerelease deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeGat committed Feb 8, 2024
1 parent 977f915 commit f3bc3c5
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ jobs:
needs:
- branch-check
outputs:
number: ${{ steps.get-version.outputs.number }}
version: ${{ steps.get-version.outputs.version-name }}
version-build: ${{ steps.get-version-build.outputs.version-build-name }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -148,13 +149,38 @@ jobs:

- name: Generate Version Number
id: get-version
# The step generates a general version number from the branch name, looking the
# same as a regular release build.
# Ex. 'pre-2024.01.1' -> '2024.01.1'
run: version-name=$(cut --delimiter '-' --field 2 <<< "${{ github.head_ref }}")

- name: Generate Version-Build String
id: get-version-build
# This step generates the version number for prereleases, which given a branch
# like `pre-<version>`, looks like: `<version>-<number of commits on this branch>`.
# Ex. `pre-2024.10.1` with 2 commits on branch -> `2024.10.1-2`.
run: |
number_of_commits=$(git rev-list --count origin/main..HEAD)
no_pre_version=$(cut --delimiter '-' --field 2 <<< "${{ github.head_ref }}")
echo "number=${no_pre_version}-${number_of_commits}" >> $GITHUB_OUTPUT
number-of-commits=$(git rev-list --count origin/main..HEAD)
echo "version-build-name=${{ steps.get-version.outputs.version-name }}-${number-of-commits}" >> $GITHUB_OUTPUT
update-prerelease-tag:
name: Update Prerelease Tag ${{ needs.prerelease-deploy-version.outputs.version }}
needs:
- prerelease-deploy-version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Push
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ needs.prerelease-deploy-version.outputs.version }} --force
git push --tags --force
prerelease-deploy:
Expand All @@ -178,5 +204,5 @@ jobs:
with:
type: prerelease
ref: ${{ github.head_ref }}
version: ${{ needs.prerelease-deploy-version.outputs.number }}
version: ${{ needs.prerelease-deploy-version.outputs.version-build }}
secrets: inherit

0 comments on commit f3bc3c5

Please sign in to comment.