Skip to content

testing multiple gitversion executions methods side-by-side #25

testing multiple gitversion executions methods side-by-side

testing multiple gitversion executions methods side-by-side #25

Workflow file for this run

name: test
on:
workflow_dispatch:
push:
branches-ignore:
- "preview/**"
paths-ignore:
- .github/dependabot.yml
- LICENSE
- README.md
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
env:
GITHUB_ACTIONS: true
jobs:
gv-via-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gittools/actions/gitversion/setup@v1
with:
versionSpec: 5.x
- uses: gittools/actions/gitversion/execute@v1
with:
useConfigFile: true
additionalArguments: /nofetch
gv-via-dotnet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: gitversion dotnet (2 of 2)
run: |
dotnet tool update -g GitVersion.Tool
$HOME/.dotnet/tools/dotnet-gitversion ${{ github.workspace }} /nofetch > GitVersion.json
cat GitVersion.json
gv-via-container: #fails with "ERROR: fatal: detected dubious ownership in repository at '/repo'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: printenv | grep GITHUB.*=
- run: |
docker run -v "${{ github.workspace }}:/repo" gittools/gitversion:6.0.0-rc.1 /repo /nofetch > GitVersion.json
cat GitVersion.json
- run: |
docker run --name gvtest -v "${{ github.workspace }}:/repo" gittools/gitversion:6.0.0-rc.1 /repo /nofetch
docker logs gvtest
if: always()
#fails with "Gitversion could not determine which branch to treat as the development branch (default is 'develop') nor release-able branch (default is 'main' or 'master'), either locally or remotely. Ensure the local clone and checkout match the requirements or considering using 'GitVersion Dynamic Repositories'"
gv-via-container-workaround1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
docker run --name gvtest --entrypoint "" -v "$(pwd):/repo" gittools/gitversion:6.0.0-rc.1 /bin/bash -c "git config --global --add safe.directory '*'; /tools/dotnet-gitversion /repo"
docker logs gvtest
gv-via-container-workaround2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0
- uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
#Note: "I'd be really interested to hear specific examples of how/where ref: ${{ github.event.pull_request.head.sha }} could get us in trouble... if you've got any."
#https://github.com/actions/checkout/issues/426#issuecomment-1881367421
- run: |
docker run --name gvtest --entrypoint "" -v "$(pwd):/repo" gittools/gitversion:6.0.0-rc.1 /bin/bash -c "git config --global --add safe.directory '*'; /tools/dotnet-gitversion /repo"
docker logs gvtest