Skip to content

Commit

Permalink
manage version via makefile, sync version
Browse files Browse the repository at this point in the history
  • Loading branch information
BeryJu committed Sep 24, 2022
1 parent 7b57640 commit 15f8b05
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
working-directory: web/
run: |
npm ci
make -C .. gen-client-web
make -C .. gen-client-ts
npm run build
- run: go get -v -t -d ./...
- name: Run coverage
Expand Down Expand Up @@ -53,18 +53,6 @@ jobs:
echo "##[set-output name=sha]$GITHUB_SHA"
echo "##[set-output name=build]$GITHUB_RUN_ID"
echo "##[set-output name=timestamp]$(date +%s)"
- name: Setup node
uses: actions/setup-node@v3.4.1
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build web
working-directory: web/
run: |
npm ci
make -C .. gen-client-web
npm run build
- name: Build and push Docker images
uses: docker/build-push-action@v3.1.1
with:
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ RUN go mod download
COPY . .
COPY --from=web-builder /work/web/dist/ /workspace/web/dist/

RUN go build \
-ldflags "-X beryju.io/gravity/pkg/extconfig.BuildHash=$GIT_BUILD_HASH" \
-v -a -o gravity .
RUN make docker-build

# Stage 3: Run
FROM docker.io/library/debian:stable-slim
Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,38 @@
PWD = $(shell pwd)
UID = $(shell id -u)
GID = $(shell id -g)
VERSION = "0.1.5"
GO_FLAGS = -ldflags "-X beryju.io/gravity/pkg/extconfig.Version=$(VERSION)" -v

docker-build:
go build \
${GO_FLAGS} \
-ldflags "-X beryju.io/gravity/pkg/extconfig.BuildHash=$(GIT_BUILD_HASH)" \
-a -o gravity .

run:
INSTANCE_LISTEN=0.0.0.0 DEBUG=true LISTEN_ONLY=true go run -v . server
INSTANCE_LISTEN=0.0.0.0 DEBUG=true LISTEN_ONLY=true go run $(GO_FLAGS) . server

gen-build:
DEBUG=true go run -v . cli generateSchema schema.yml
DEBUG=true go run $(GO_FLAGS) . cli generateSchema schema.yml

gen-clean:
rm -rf gen-ts-api/

gen-client-web:
gen-client-ts:
docker run \
--rm -v ${PWD}:/local \
--user ${UID}:${GID} \
openapitools/openapi-generator-cli:v6.0.0 generate \
-i /local/schema.yml \
-g typescript-fetch \
-o /local/gen-ts-api \
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=gravity-api,npmVersion=0.1.0 \
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=gravity-api,npmVersion=$(VERSION) \
--git-repo-id BeryJu \
--git-user-id gravity
mkdir -p web/node_modules/gravity-api
cd gen-ts-api && npm i
\cp -rfv gen-ts-api/* web/node_modules/gravity-api

gen: gen-build gen-clean gen-client-web
gen: gen-build gen-clean gen-client-ts

test-etcd-start:
docker run \
Expand Down
2 changes: 1 addition & 1 deletion schema.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: gravity
version: 0.0.1
version: 0.1.5
paths:
/api/v1/auth/config:
get:
Expand Down
14 changes: 7 additions & 7 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"eslint-config-google": "^0.14.0",
"eslint-plugin-custom-elements": "0.0.6",
"eslint-plugin-lit": "^1.6.1",
"gravity-api": "^0.1.3",
"gravity-api": "^0.1.5",
"lit": "^2.3.1",
"prettier": "^2.7.1",
"rollup": "^2.79.1",
Expand Down

0 comments on commit 15f8b05

Please sign in to comment.