Skip to content

Commit

Permalink
feat: store VERSION in the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Jan 13, 2025
1 parent d39e075 commit 81fc144
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ jobs:
env:
REF: ${{ github.ref }}
run: |
versionFile=$(cat VERSION | tr -d '[:space:]')
if [[ $REF == refs/tags/* ]]; then
echo -n "${REF#refs/tags/}" > .release_version
# check if versionFile equals the tag.
if [[ $versionFile != "${REF#refs/tags/}" ]]; then
echo "Version in VERSION file does not match the tag"
exit 1
fi
else
v=$(git rev-parse --short HEAD) && echo -n $v > .release_version
# if this isnt a release, add the commit hash to the end of the version
v=$(git rev-parse --short HEAD) echo -n "${versionFile}+${v}" > VERSION
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -81,7 +87,7 @@ jobs:
REGISTRY: "public.ecr.aws/z6g0f8n7"
REPOSITORY: ${{ github.event.repository.name }}
run: |
VERSION=$(cat .release_version)
VERSION=$(cat VERSION)
if [[ $GITHUB_REF == refs/heads/master || $GITHUB_REF == refs/tags/* ]]; then
docker buildx build --platform "linux/amd64,linux/arm64" -t $REGISTRY/$REPOSITORY:$VERSION -t $REGISTRY/$REPOSITORY:latest --push .
else
Expand All @@ -95,18 +101,21 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set release version
- name: Check and set release version
env:
REF: ${{ github.ref }}
run: |
versionFile=$(cat VERSION | tr -d '[:space:]')
if [[ $REF == refs/tags/* ]]; then
echo -n "${REF#refs/tags/}" > .release_version
# check if versionFile equals the tag.
if [[ $versionFile != "${REF#refs/tags/}" ]]; then
echo "Version in VERSION file does not match the tag"
exit 1
fi
else
v=$(git rev-parse --short HEAD) && echo -n $v > .release_version
fi
- name: Build binary
run: |
VERSION=$(cat .release_version)
VERSION=$(cat VERSION)
echo "Building binary for version $VERSION"
make release
./scripts/bundleReleases.sh $VERSION
Expand All @@ -127,7 +136,6 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
REF: ${{ github.ref }}
run: |
set -x
ls -al ./release
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GO=$(shell which go)
ALL_FLAGS=
GO_FLAGS=-ldflags "-X 'github.com/Layr-Labs/sidecar/internal/version.Version=$(shell cat .release_version)' -X 'github.com/Layr-Labs/sidecar/internal/version.Commit=$(shell git rev-parse --short HEAD)'"
GO_FLAGS=-ldflags "-X 'github.com/Layr-Labs/sidecar/internal/version.Version=$(shell cat VERSION)' -X 'github.com/Layr-Labs/sidecar/internal/version.Commit=$(shell git rev-parse --short HEAD)'"

deps/dev:
${GO} install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.1.0

0 comments on commit 81fc144

Please sign in to comment.