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

Fix version.go (Rollback to only use OCCoreSemVer) #348

Merged
merged 4 commits into from
Nov 30, 2021
Merged
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
38 changes: 21 additions & 17 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build & Push
# Build & Push rebuilds the ostracon docker image on every push to master and creation of tags
# Build & Push rebuilds the ostracon docker image on every push to main and creation of tags
# and pushes the image to https://hub.docker.com/r/interchainio/simapp/tags
on:
pull_request:
Expand All @@ -24,23 +24,27 @@ jobs:
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
DEFAULT_BRANCH=$(curl -s -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/line/ostracon | \
grep default_branch | \
cut -d"\"" -f4)
if [ "$DEFAULT_BRANCH" = "$VERSION" ]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION%.*}"
fi
echo ::set-output name=tags::${TAGS}

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
# - name: Set up QEMU
# uses: docker/setup-qemu-action@master
# with:
# platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# if: ${{ github.event_name != 'pull_request' }}
Expand All @@ -49,11 +53,11 @@ jobs:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
file: ./DOCKER/Dockerfile
platforms: linux/amd64,linux/arm64
#push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
# - name: Publish to Docker Hub
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./DOCKER/Dockerfile
# platforms: linux/amd64,linux/arm64
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.prep.outputs.tags }}
35 changes: 22 additions & 13 deletions .github/workflows/proto-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
pull_request:
paths:
- "tools/proto/*"
# push:
# paths:
# - "tools/proto/*"
push:
branches:
- main
paths:
- "tools/proto/*"
schedule:
# run this job once a month to recieve any go or buf updates
- cron: "* * 1 * *"
Expand All @@ -24,26 +26,33 @@ jobs:
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
DEFAULT_BRANCH=$(curl -s -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/line/ostracon | \
grep default_branch | \
cut -d"\"" -f4)
if [ "$DEFAULT_BRANCH" = "$VERSION" ]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION%.*}"
fi
echo ::set-output name=tags::${TAGS}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish to Docker Hub
uses: docker/build-push-action@v2
with:
context: ./tools/proto
file: ./tools/proto/Dockerfile
push: false #${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
# - name: Publish to Docker Hub
# uses: docker/build-push-action@v2
# with:
# context: ./tools/proto
# file: ./tools/proto/Dockerfile
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.prep.outputs.tags }}
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ builds:
- id: "Ostracon"
main: ./cmd/ostracon/main.go
ldflags:
- -s -w -X github.com/line/ostracon/version.Version={{ .Version }}
- -s -w -X github.com/line/ostracon/version.OCCoreSemVer={{ .Version }}
env:
- CGO_ENABLED=0
goos:
Expand Down
10 changes: 3 additions & 7 deletions DOCKER/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
set -e

# Get the tag from the version, or try to figure it out.
if [ -z "$TAG" ]; then
TAG=$(awk -F\" '/Version =/ { print $2; exit }' < ../version/version.go)
fi
if [ -z "$TAG" ]; then
echo "Please specify a tag."
exit 1
echo "Please specify a tag."
exit 1
fi

TAG_NO_PATCH=${TAG%.*}
Expand All @@ -16,5 +12,5 @@ read -p "==> Build 3 docker images with the following tags (latest, $TAG, $TAG_N
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker build -t "ostracon/ostracon" -t "ostracon/ostracon:$TAG" -t "ostracon/ostracon:$TAG_NO_PATCH" .
docker build -t "ostracon/ostracon" -t "ostracon/ostracon:$TAG" -t "ostracon/ostracon:$TAG_NO_PATCH" -f ./Dockerfile ../
fi
8 changes: 2 additions & 6 deletions DOCKER/push.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
set -e

# Get the tag from the version, or try to figure it out.
if [ -z "$TAG" ]; then
TAG=$(awk -F\" '/Version =/ { print $2; exit }' < ../version/version.go)
fi
if [ -z "$TAG" ]; then
echo "Please specify a tag."
exit 1
echo "Please specify a tag."
exit 1
fi

TAG_NO_PATCH=${TAG%.*}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
BUILD_TAGS += r2ishiguro
LIBSODIUM_TARGET =
endif
LD_FLAGS = -X github.com/line/ostracon/version.Version=$(VERSION)
LD_FLAGS = -X github.com/line/ostracon/version.OCCoreSemVer=$(VERSION)
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
HTTPS_GIT := https://github.com/line/ostracon.git
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf
Expand Down
2 changes: 1 addition & 1 deletion cmd/ostracon/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ var VersionCmd = &cobra.Command{
Use: "version",
Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
fmt.Println(version.OCCoreSemVer)
},
}
11 changes: 11 additions & 0 deletions cmd/ostracon/commands/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package commands

import (
"github.com/line/ostracon/version"
"testing"
)

func TestVersionCmd(t *testing.T) {
version.OCCoreSemVer = "test version"
VersionCmd.Run(VersionCmd, nil)
}
14 changes: 4 additions & 10 deletions scripts/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ set -e
# WARN: non hermetic build (people must run this script inside docker to
# produce deterministic binaries).

# Get the version from the environment, or try to figure it out.
if [ -z $VERSION ]; then
VERSION=$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go)
fi
if [ -z "$VERSION" ]; then
echo "Please specify a version."
exit 1
echo "Please specify a version."
exit 1
fi
echo "==> Building version $VERSION..."

Expand All @@ -19,8 +15,6 @@ echo "==> Removing old directory..."
rm -rf build/pkg
mkdir -p build/pkg

# Get the git commit
VERSION := "$(git describe --always)"
GIT_IMPORT="github.com/line/ostracon/version"

# Determine the arch/os combos we're building for
Expand All @@ -41,7 +35,7 @@ for arch in "${arch_list[@]}"; do
for os in "${os_list[@]}"; do
if [[ "$XC_EXCLUDE" != *" $os/$arch "* ]]; then
echo "--> $os/$arch"
GOOS=${os} GOARCH=${arch} go build -ldflags "-s -w -X ${GIT_IMPORT}.Version=${VERSION}" -tags="${BUILD_TAGS}" -o "build/pkg/${os}_${arch}/ostracon" ./cmd/ostracon
GOOS=${os} GOARCH=${arch} go build -ldflags "-s -w -X ${GIT_IMPORT}.OCCoreSemVer=${VERSION}" -tags="${BUILD_TAGS}" -o "build/pkg/${os}_${arch}/ostracon" ./cmd/ostracon
fi
done
done
Expand All @@ -61,7 +55,7 @@ done
rm -rf ./build/dist
mkdir -p ./build/dist
for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do
FILENAME=$(basename "$FILENAME")
FILENAME=$(basename "$FILENAME")
cp "./build/pkg/${FILENAME}" "./build/dist/ostracon_${VERSION}_${FILENAME}"
done

Expand Down
4 changes: 2 additions & 2 deletions tools/tm-signer-harness/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG TENDERMINT_VERSION=latest
FROM ostracon/ostracon:${TENDERMINT_VERSION}
ARG OSTRACON_VERSION=latest
FROM ostracon/ostracon:${OSTRACON_VERSION}

COPY tm-signer-harness /usr/bin/tm-signer-harness
2 changes: 1 addition & 1 deletion tools/tm-signer-harness/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
OSTRACON_VERSION?=latest
BUILD_TAGS?='ostracon'
VERSION := $(shell git describe --always)
BUILD_FLAGS = -ldflags "-X github.com/line/ostracon/version.Version=$(VERSION)
BUILD_FLAGS = -ldflags "-X github.com/line/ostracon/version.OCCoreSemVer=$(VERSION)"

.DEFAULT_GOAL := build

Expand Down
15 changes: 0 additions & 15 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@ var (
// OCCoreSemVer is the current version of Ostracon Core.
// It's the Semantic Version of the software.
OCCoreSemVer string

// GitCommit is the current HEAD set using ldflags.
GitCommit string

// Version is the built softwares version.
Version = OCCoreSemVer + "-" + LINECoreSemVer
)

func init() {
if GitCommit != "" {
Version += "-" + GitCommit
}
}

const (
// LINECoreSemVer is the current version of LINE Ostracon Core.
LINECoreSemVer = "0.3"

// ABCISemVer is the semantic version of the ABCI library
ABCISemVer = "0.17.0"

Expand Down