Browse Source

Setting up automatic build uploading

pull/66/head
Atridad Lahiji 3 weeks ago
parent
commit
6d45f8680f
  1. 60
      .drone.yml
  2. 29
      build-backend.sh
  3. 6
      build-frontend.sh
  4. 35
      build.sh

60
.drone.yml

@ -1,19 +1,67 @@
kind: pipeline
type: docker
name: build
name: dev
trigger:
event:
- push
branch:
- develop
event:
- push
steps:
- image: node
name: frontend
name: test-build-frontend
commands:
- cd ./frontend
- npm install
- npm run build
- image: golang
name: backend
name: test-build-backend
commands:
- go build
---
kind: pipeline
type: docker
name: prod
trigger:
event:
- tag
steps:
- image: node
name: build-frontend
commands:
- chmod +x ./build-frontend.sh
- ./build-frontend.sh
- image: golang
name: build-backend
commands:
- chmod +x ./build-frontend.sh
- ./build-backend.sh
- image: node
name: pre-upload
commands:
- go build
- curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > jq
- chmod +x ./jq
- LATEST_RELEASE_ID=$(curl -s https://git.atrilahiji.dev/api/v1/repos/atrilahiji/EleutheriaPay/releases | ./jq '.[0].id')
- rm -rf bin/darwin-amd64
- rm -rf bin/linux-amd64
- mv bin/darwin-amd64.tar.gz bin/$LATEST_RELEASE_ID-darwin-amd64.tar.gz
- mv bin/linux-amd64.tar.gz bin/$LATEST_RELEASE_ID-linux-amd64.tar.gz
- image: plugins/s3
name: upload
settings:
access_key:
from_secret: S3_ACCESS
secret_key:
from_secret: S3_SECRET
bucket: eleutheriapay
source: bin/*
target: /downloads/
path_style: true
endpoint: https://s3.atrilahiji.dev

29
build-backend.sh

@ -0,0 +1,29 @@
#!/bin/bash
# build backend
VERSION="1.2.1"
export OLD_GOOS=$(go env GOOS)
export OLD_GOARCH=$(go env GOARCH)
mkdir bin
# buid for macos x86 64-bit
export GOOS=darwin
export GOARCH=amd64
mkdir bin/$(go env GOOS)-$(go env GOARCH)
cp .env.example ./bin/$(go env GOOS)-$(go env GOARCH)/.env.example
cp -r ./assets ./bin/$(go env GOOS)-$(go env GOARCH)
go build -o ./bin/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
$(go env GOPATH)/bin/rice append --exec ./bin/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
tar -czvf ./bin/$(go env GOOS)-$(go env GOARCH).tar.gz ./bin/$(go env GOOS)-$(go env GOARCH)
# buid for linux x86 64-bit
export GOOS=linux
export GOARCH=amd64
mkdir bin/$(go env GOOS)-$(go env GOARCH)
cp .env.example ./bin/$(go env GOOS)-$(go env GOARCH)/.env.example
cp -r ./assets ./bin/$(go env GOOS)-$(go env GOARCH)
go build -o ./bin/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
$(go env GOPATH)/bin/rice append --exec ./bin/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
tar -czvf ./bin/$(go env GOOS)-$(go env GOARCH).tar.gz ./bin/$(go env GOOS)-$(go env GOARCH)

6
build-frontend.sh

@ -0,0 +1,6 @@
#!/bin/bash
# build frontend
cd ./frontend
npm install
npm run build

35
build.sh

@ -1,35 +0,0 @@
#!/bin/bash
VERSION="1.2.1"
# build frontend
cd ./frontend
npm install
npm run build
export OLD_GOOS=$(go env GOOS)
export OLD_GOARCH=$(go env GOARCH)
# build backend
cd ..
mkdir bin
mkdir bin/$VERSION
# buid for macos x86 64-bit
export GOOS=darwin
export GOARCH=amd64
mkdir bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
cp .env.example ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/.env.example
cp -r ./assets ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
go build -o ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
$(go env GOPATH)/bin/rice append --exec ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
tar -czvf ./bin/$VERSION/$VERSION-$(go env GOOS)-$(go env GOARCH).tar.gz ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
# buid for linux x86 64-bit
export GOOS=linux
export GOARCH=amd64
mkdir bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
cp .env.example ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/.env.example
cp -r ./assets ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
go build -o ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
$(go env GOPATH)/bin/rice append --exec ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)/eleutheriapay-$VERSION-$(go env GOOS)-$(go env GOARCH)
tar -czvf ./bin/$VERSION/$VERSION-$(go env GOOS)-$(go env GOARCH).tar.gz ./bin/$VERSION/$(go env GOOS)-$(go env GOARCH)
Loading…
Cancel
Save