Skip to content

Conversation

@mcasperson
Copy link
Contributor

Github actions can take advantage of the GitVersion docker image, but they ignore the working directory, so the entrypoint ["dotnet", "GitVersion.dll"] fails to load. Pointing to the absolute path for the DLL solves the issue.

@arturcic
Copy link
Member

Looks good to me! Thanks for the contribution 👍. Could you please provide details on how use use the Github actions with GitVersion docker image? Just curious.

@arturcic arturcic added this to the 5.1.0 milestone Aug 21, 2019
@arturcic arturcic merged commit 822ec81 into GitTools:master Aug 21, 2019
@gep13
Copy link
Member

gep13 commented Aug 21, 2019

@mcasperson @arturcic I would be curious about how you are doing this as well. Would a dedicated GitHub Action for GitVersion make sense?

@mcasperson
Copy link
Contributor Author

mcasperson commented Aug 21, 2019

Getting values out of a Github action seems a little clunky at the moment, but you can save the version to a file and consume that in another step like this:

name: Python package

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Get Git Version
      uses: docker://gittools/gitversion:5.0.2-linux-centos-7-netcoreapp2.2
      with:
        args: /github/workspace /nofetch /exec /bin/sh /execargs "-c \"echo $GitVersion_MajorMinorPatch > /github/workspace/version.txt\""

The directory /github/workspace is shared across actions, so the version.txt file will be available for subsequent steps.

Versioning with GitHub actions is a huge hole at the moment. Almost every CI action would benefit from being able to access a sensible incrementing version, and GitVersion is the only thing that I have seen (beyond date based versions) that can fill this.

@mcasperson
Copy link
Contributor Author

https://octopus.com/blog/versioning-with-github-actions describes how we have taken advantage of this feature.

@arturcic
Copy link
Member

Great article @mcasperson! A quick question, have you considered using
/showvariable FullSemVer as argument instead of calling bash to output the env variable?

@mcasperson
Copy link
Contributor Author

mcasperson commented Aug 30, 2019

@arturcic The challenge with GitHub actions is sharing the result with subsequent jobs. GA doesn't capture the output of a command, so for that version value to be made available it has to be saved in a file because the filesystem is shared between GA jobs. Calling bash via /exec looked like the easiest way to use an unmodified docker image and generate a file with the version contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants