Skip to content

Commit

Permalink
Setup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorChristie committed Mar 1, 2020
1 parent f9abb2d commit 0003e1e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 21 deletions.
16 changes: 7 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
at: '~/project'
- run:
name: "Compile"
command: GOOS=linux GOARCH=amd64 ./wizard.sh -c
command: ./wizard.sh -c
- run:
name: "Cleanup"
command: |
rm -rf frontend/build
git checkout -- go.sum # TODO: why is it being changed?
git checkout -- go.sum
- persist_to_workspace:
root: .
paths:
Expand All @@ -45,10 +45,9 @@ jobs:
steps:
- attach_workspace:
at: '~/project'
- setup_remote_docker
- run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- run: curl -sL https://git.io/goreleaser | bash
- run: docker logout
- run:
name: "Release"
command: ./wizard.sh -r $CIRCLE_TAG
workflows:
version: 2
build-workflow:
Expand All @@ -66,14 +65,13 @@ workflows:
tags:
only: /.*/
requires:
- build-node
- lint
- build-node
- release:
context: deploy
requires:
- build-go
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
ignore: /.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ filebrowser
.DS_Store
node_modules
/frontend/dist
out/

# local env files
.env.local
Expand Down
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
os: linux
services: docker
language: go
go:
- 1.12.x
install: skip
addons:
apt:
packages:
- pass
env:
global:
- USE_DOCKER="true"
- GO111MODULE=on
stages:
- lint
- build
- release
cache:
directories:
- http/rice-box.go
jobs:
include:
- stage: lint
script: ./wizard.sh -l
- stage: build
script: ./wizard.sh -b
deploy:
provider: script
skip_cleanup: true
script: ./wizard.sh -p
on:
tags: false
repo: filebrowser/filebrowser
branch: master
- stage: release
script: ./wizard.sh -r "$TRAVIS_TAG"
if: tag IS present
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: GCURbl9xmjOmeNc7cYSvfSwbEp46cacWmJRczcsU6rQa0aWqzjELYdyIsl6HWW+o0dzuZvbWRD6muxYqIud92oPLYDuXSnra9tM3mCjswrjiPCJ57bksWkSPBfFQcxIyB6c3o+A/FMnX3nnSE/2r5HYZnPNFbEcBbC7WSgwx9ejXUuyWn1PUFK9YQWANdl6J7b7EKsk+9MxS9Pmw6M2ycBwX8ScUQdofkUPvR/nqlXISm+3hs30VubqQi9Ha6DM9Bw3aFK3/Ts/ujCOxP1ZoMCBZ6tfnaQOElIG96WTwnt77eDYlZezBOLym3Z18iif+Qny+XndFKDbexaiUT06VlWFXCKtt3iLs6HJwRcjmiHmB0Z3v+W4cKPl3cEyxxrU2aal54k1PBhU+5L0Xc8ileKbDMYg5tps88zWHNefeZVfaxYSVrmUHkuygMe481oaBLacDXTxs4t6XEpStREuLmvx9NLTwTFAbWjMNM0PqlueDMxO4bdwNvzXg/TcKLWV9FezqAlre8lFNZK5wX6lKFVSZ3hFjxCfwrJL2cPwg5A8Yd5EOC4Nh81WdgYuFGOxZzMAoSJlaVRvQS1trCUP/++ONnDep3ExSxvw4B7vijGZWeXUhrOMiPQHXu+t6BnrlnDjQ4gi44QTW0y/iM2WC2DBKfgYjAKwyHx13hFrmOCg=
file: "dist/*.*"
file_glob: true
on:
repo: filebrowser/filebrowser
all_branches: true
tags: true
35 changes: 23 additions & 12 deletions wizard.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/bin/bash

set -e

Expand Down Expand Up @@ -43,7 +43,26 @@ buildBinary () {
rice embed-go

cd $REPO
go build -a -o filebrowser -ldflags "-s -w -X github.com/filebrowser/filebrowser/v2/version.CommitSHA=$COMMIT_SHA"
rm -rf out

platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/amd64" "linux/arm64" "linux/arm")

for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name='filebrowser-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi

env GOOS=$GOOS GOARCH=$GOARCH go build -a -o out/$output_name -ldflags "-s -w -X github.com/ConnorChristie/filebrowser/v2/version.CommitSHA=$COMMIT_SHA"
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done
}

release () {
Expand All @@ -68,16 +87,8 @@ release () {
exit 1
fi

echo "🧼 Tidying up go modules"
go mod tidy

echo "🐑 Creating a new commit for the new release"
git commit --allow-empty -am "chore: version $semver"
git tag "$1"
git push
git push --tags origin

echo "📦 Done! $semver released."
go get github.com/tcnksm/ghr
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -c $CIRCLE_SHA1 -delete $semver ./out/
}

usage() {
Expand Down

0 comments on commit 0003e1e

Please sign in to comment.