Skip to content

Commit

Permalink
ci tweaks (#15)
Browse files Browse the repository at this point in the history
* split off versioning wf

* fixup versioning
  • Loading branch information
f2calv authored Jun 25, 2023
1 parent 25794e5 commit bd394e4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 38 deletions.
48 changes: 10 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,39 @@ on:
types: [opened, synchronize, reopened]

jobs:
versioning:
uses: ./.github/workflows/versioning.yml

build_app:
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}

needs: versioning
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: .NET 7.x SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

- name: gitversion (1 of 2)
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: 5.x

- name: gitversion (2 of 2)
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
additionalArguments: /nofetch

- name: dotnet restore
run: dotnet restore --verbosity minimal --configfile NuGet.config

- name: dotnet build
run: dotnet build -c Release --nologo --no-restore -p:Version='${{ steps.gitversion.outputs.fullSemVer }}' -p:SourceRevisionId=${{ github.sha }}
run: dotnet build -c Release --nologo --no-restore -p:Version='${{ needs.versioning.outputs.fullSemVer }}' -p:SourceRevisionId=${{ github.sha }}

#TODO: could run dotnet test here, etc...

build_image:
runs-on: ubuntu-latest
needs: build_app

needs: [versioning, build_app]
#https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/
#https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions:
packages: write #for pushing container image

env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
GIT_REPO: ${{ github.repository }}
GIT_TAG: ${{ needs.build_app.outputs.semVer }}
GIT_TAG: ${{ needs.versioning.outputs.semVer }}
GIT_BRANCH: ${{ github.ref }}
GIT_COMMIT: ${{ github.sha }}

steps:
- uses: actions/checkout@v3
# with:
# fetch-depth: 0

- name: set vars (1 of 2)
run: |
Expand Down Expand Up @@ -132,20 +108,17 @@ jobs:
push_chart:
runs-on: ubuntu-latest
needs: [build_app, build_image]
needs: [versioning, build_app, build_image]
if: github.ref == 'refs/heads/main'

permissions:
packages: write #for pushing helm package
contents: write #for creating releases/tags

env:
REGISTRY: ghcr.io
#CHART_REPOSITORY: Note: set dynamically, i.e. github.repository_owner/charts/IMAGE_NAME
GIT_TAG: ${{ needs.build_app.outputs.semVer }}
GIT_TAG: ${{ needs.versioning.outputs.semVer }}
HELM_EXPERIMENTAL_OCI: 1
HELM_VERSION_TO_INSTALL: 3.9.2 #Note: keep this version in sync inside the devcontainer

steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -220,5 +193,4 @@ jobs:
uses: f2calv/gha-workflows/.github/workflows/gha-release-versioning.yml@v1
with:
tag-prefix: ''
move-major-tag: false

move-major-tag: false
39 changes: 39 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci

on:
workflow_call:
outputs:
semVer:
description: e.g. 1.2.3
value: ${{ jobs.get-version.outputs.semVer }}
fullSemVer:
description: e.g. 1.2.3-branchname-feature.3
value: ${{ jobs.get-version.outputs.fullSemVer }}

jobs:
get-version:
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: .NET 7.x SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

- name: gitversion (1 of 2)
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: 5.x

- name: gitversion (2 of 2)
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
additionalArguments: /nofetch

0 comments on commit bd394e4

Please sign in to comment.