Skip to content

Commit

Permalink
Versioning changes (#13)
Browse files Browse the repository at this point in the history
* enable prereleases

* pass is-prerelease

* only release on main

* from json
  • Loading branch information
Confusingboat authored Mar 18, 2024
1 parent 700504d commit 56628f4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 36 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build & Test
name: Build, Test, Release

on:
workflow_dispatch:
Expand Down Expand Up @@ -68,16 +68,6 @@ jobs:
name: test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx

# - name: Test Results Comment
# if: always()
# uses: im-open/[email protected]
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# timezone: ${{ env.TIMEZONE }}
# create-status-check: false
# create-pr-comment: true
# comment-identifier: 'TestResults'

# Cosmos DB Emulator is broken on Ubuntu
# https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/56

Expand Down Expand Up @@ -141,16 +131,6 @@ jobs:
name: cosmos-test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx

# - name: Test Results Comment
# if: always()
# uses: im-open/[email protected]
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# timezone: ${{ env.TIMEZONE }}
# create-status-check: false
# create-pr-comment: true
# comment-identifier: 'CosmosTestResults'

test_results_comment:
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -180,13 +160,24 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/tag.yml

test-tag-output:
runs-on: ubuntu-latest
needs:
- tag
steps:
- name: Echo tag output
run: |
echo prerelease-depth: "${{ fromJSON(needs.tag.outputs.prerelease-depth) }}"
echo is-prerelease: "${{ fromJSON(needs.tag.outputs.is-prerelease) }}"
release:
needs:
- tag
- build_and_test
- build_and_test_cosmos
if: ${{ github.event_name != 'pull_request' && needs.tag.outputs.prerelease-depth < 2 }}
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && fromJSON(needs.tag.outputs.prerelease-depth) < 2 }}
uses: ./.github/workflows/release.yml
with:
version: ${{ needs.tag.outputs.version }}
is-prerelease: ${{ needs.tag.outputs.is-prerelease }}
secrets: inherit
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Release
name: Pack & Release

on:
workflow_call:
inputs:
version:
required: true
type: string
is-prerelease:
required: true
type: boolean
secrets:
NUGET_ORG_API_KEY:
required: true
Expand Down Expand Up @@ -54,7 +57,7 @@ jobs:
uses: ncipollo/release-action@v1
with:
tag: v${{ inputs.version }}
prerelease: ${{ contains(inputs.version, '-') }}
prerelease: ${{ inputs.is-prerelease }}
artifacts: "${{ env.ArtifactDirectory }}/*.nupkg"

- name: Publish to pkg.github.com
Expand Down
40 changes: 28 additions & 12 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
prerelease-depth:
description: "Number of periods in the prerelease version"
value: ${{ jobs.tag.outputs.prerelease-depth }}
is-prerelease:
description: "Boolean string indicating whether the version is a prerelease"
value: ${{ jobs.tag.outputs.is-prerelease }}

env:
#MinVerIgnoreHeight: true
Expand All @@ -36,7 +39,8 @@ jobs:
minor: ${{ steps.version.outputs.minor }}
patch: ${{ steps.version.outputs.patch }}
prerelease: ${{ steps.version.outputs.prerelease }}
prerelease-depth: ${{ steps.get-prerelease-depth.outputs.prerelease_depth }}
prerelease-depth: ${{ steps.set-prerelease-depth.outputs.prerelease_depth }}
is-prerelease: ${{ steps.set-is-prerelease.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -51,36 +55,48 @@ jobs:
tag-prefix: v
default-pre-release-phase: preview

- name: echo version #version major minor patch prerelease
- name: Echo version #version major minor patch prerelease
run: |
echo Version: ${{ steps.version.outputs.version }}
echo version: ${{ steps.version.outputs.version }}
echo major: ${{ steps.version.outputs.major }}, minor: ${{ steps.version.outputs.minor }}, patch: ${{ steps.version.outputs.patch }}
echo prerelease: ${{ steps.version.outputs.prerelease }}
- name: get prerelease depth
id: get-prerelease-depth
- name: Set prerelease depth
id: set-prerelease-depth
run: |
echo "prerelease_depth=$(echo '${{ steps.version.outputs.prerelease }}' | tr -cd '.' | wc -c | tr -d ' ')" >> "$GITHUB_OUTPUT"
- run: echo "${{ steps.get-prerelease-depth.outputs.prerelease_depth }}"
- name: Echo prerelease depth
run: echo "${{ steps.set-prerelease-depth.outputs.prerelease_depth }}"

- name: Set is-prerelease
id: set-is-prerelease
run: |
echo "is_prerelease=$(echo '${{ contains(steps.version.outputs.version, '-') && 'true' || 'false' }}')" >> "$GITHUB_OUTPUT"
- name: Echo is-prerelease
run: echo "${{ steps.set-is-prerelease.outputs.is_prerelease }}"

# - run: |
# git tag v${{ steps.version.outputs.version }}
# git push --tags
- name: Tag version
if: ${{ github.ref == 'refs/heads/main' }}
run: |
git tag v${{ steps.version.outputs.version }}
git push --tags
# Update unstable tag on main branch
- name: unstable tag
- name: Tag unstable
if: ${{ github.ref == 'refs/heads/main' }}
uses: EndBug/[email protected]
with:
ref: unstable

# Update latest tag on main branch when tagged RTM
- name: latest tag
- name: Tag latest
if: ${{ github.ref == 'refs/heads/main' && steps.version.outputs.prerelease == '' }}
uses: EndBug/[email protected]

# - name: Version tag
# - name: Tag version
# if: ${{ github.ref == 'refs/heads/main' }}
# uses: EndBug/[email protected]
# with:
# ref: v${{ steps.version.outputs.version }}

0 comments on commit 56628f4

Please sign in to comment.