diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83ac773d..357e6d4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/Makefile b/Makefile index fba5743e..6bd9d665 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..795460fc --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v1.1.0