Skip to content

Commit

Permalink
Some more hackery attempting to get environment variables shared betw…
Browse files Browse the repository at this point in the history
  • Loading branch information
open-collar committed Dec 8, 2019
1 parent 58dbb3e commit f9959c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:

- name: Set version number environment variables
run: |
export VERSION_REVISION="$BUILD_NUMBER"
echo "::set-env VERSION_REVISION=$BUILD_NUMBER"
echo "$VERSION_REVISION" > .version/revision.txt
export VERSION_MAJOR=$(<.version/major.txt)
export VERSION_MINOR=$(<.version/minor.txt)
echo "::set-env VERSION_MAJOR=$(<.version/major.txt)
echo "::set-env VERSION_MINOR=$(<.version/minor.txt)
echo "$VERSION_MAJOR.$VERSION_MINOR.$VERSION_REVISION" > .version/version.txt
export VERSION=$(<.version/version.txt)
echo "::set-env VERSION=$(<.version/version.txt)
echo "Version: $VERSION"
- name: Build with dotnet
Expand Down

4 comments on commit f9959c7

@jackfletch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@open-collar
I see you had some trouble with env variables in GitHub actions and wanted to offer some help. This commit is close but not quite the correct syntax (see docs). The syntax is a bit weird; here's what you want:

echo "::set-env name=VERSION_REVISION::$BUILD_NUMBER"
echo "$VERSION_REVISION" > .version/revision.txt
echo "::set-env name=VERSION_MAJOR::$(<.version/major.txt)"
echo "::set-env name=VERSION_MINOR::$(<.version/minor.txt)"
echo "$VERSION_MAJOR.$VERSION_MINOR.$VERSION_REVISION" > .version/version.txt
echo "::set-env name=VERSION::$(<.version/version.txt)"
echo "Version: $VERSION"

and if you don't use .version/version.txt, simplified to

echo "::set-env name=VERSION_REVISION::$BUILD_NUMBER"
echo "$VERSION_REVISION" > .version/revision.txt
echo "::set-env name=VERSION_MAJOR::$(<.version/major.txt)"
echo "::set-env name=VERSION_MINOR::$(<.version/minor.txt)"
echo "::set-env name=VERSION::$VERSION_MAJOR.$VERSION_MINOR.$VERSION_REVISION"
echo "Version: $VERSION"

$VERSION_REVISION, $VERSION_MAJOR, $VERSION_MINOR, and $VERSION will then be available as variables in the remaining action steps. E.g. echo "Version: $VERSION".

@open-collar
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's brilliant, thank you very much. I hope to look at this properly in a few days, after the Christmas chaos has died down.

@open-collar
Copy link
Owner Author

@open-collar open-collar commented on f9959c7 Dec 26, 2019 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfletch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to help!

Please sign in to comment.