Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store VERSION in the repo #183

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | tr -d '[:space:]' | sed 's/+/_/g')
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 | tr -d '[:space:]')
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
Loading