~romuloalves/crypt-transfer

c8677ae2ec287ba88a3d3f2d1dad67c1ef303d28 — romuloalves 3 months ago dac60c1
Configures build
2 files changed, 58 insertions(+), 48 deletions(-)

M .build.yml
D makefile
M .build.yml => .build.yml +58 -28
@@ 1,42 1,72 @@
image: archlinux
repositories:
        sr.ht: https://mirror.sr.ht/archlinux/sr.ht/#C0AAFC1676BD998617C94C42DC59670F1EB0A189
artifacts:
        - crypt-transfer-releases/v0.1.0.zip
environment:
        project: crypt-transfer
        releases: crypt-transfer-releases
        version: v0.1.0
image: alpine/edge
packages:
        - go
        - docker
        - zip
        - git
sources:
        - https://git.sr.ht/~romuloalves/crypt-transfer
        - git@gitlab.com:romuloalves/crypt-transfer-releases.git
environment:
        project: crypt-transfer
        version: v0.1.0
        releases: crypt-transfer-releases
shell: true
secrets:
        - d1a642c5-ae16-4487-be09-744d1b263255
shell: true
sources:
        - https://git.sr.ht/~romuloalves/crypt-transfer#dac60c1cf542065b4f0e8484e21f6b0c7c884734
        - git@gitlab.com:romuloalves/crypt-transfer-releases.git
tasks:
        - deps: |
                go get github.com/karalabe/xgo
                  # Downloads/installs the dependencies

                  # Go
                  go get github.com/karalabe/xgo

                  # Docker
                  # https://todo.sr.ht/~sircmpwn/builds.sr.ht/223
                  sudo service cgroups start
                  sudo nohup dockerd --bip 172.18.0.1/16 </dev/null >/dev/null 2>&1 &
                  sleep 10
                  sudo addgroup $USER docker

        - build: |
                cd ${project}
                echo "> Creating `dist` dir"
                mkdir -p dist
                echo "> Building"
                ~/go/bin/xgo -out "dist/crypt-transfer-${version}" --targets=linux/*,windows/*,darwin/* .
                  # Builds the executables

                  export GOPATH=$HOME/go

                  # Moves project to $GOPATH
                  mkdir --parents go/src/git.sr.ht/romuloalves
                  cp -R ${project} go/src/git.sr.ht/romuloalves/${project}

                  cd go/src/git.sr.ht/romuloalves/${project}

                  # Builds
                  mkdir -p dist
                  ~/go/bin/xgo -out dist/crypt-transfer-${version} --targets=linux/*,windows/*,darwin/* .

        - compress: |
                folder="crypt-transfer-${version}"
                cd ${project}
                echo "> Renaming dist folder"
                mv dist $folder
                echo "> Zipping"
                zip -r "${version}.zip" $folder
                  # Compresses the artifacts into a zip

                  folder="crypt-transfer-${version}"
                  cd go/src/git.sr.ht/romuloalves/${project}
                  mv dist $folder
                  zip -r $HOME/${releases}/${version}.zip $folder

        - deploy: |
                mv ${project}/${version}.zip ${releases}/${version}.zip
                cd ${releases}
                git add .
                git commit -m "Releases ${version}"
                git push origin master
                  # Adds the zip to the release repo on GitLab

                  # Sets git user config
                  git config --global user.name "sourcehut builds"
                  git config --global user.email builds@sr.ht

                  # Adds zip to repo
                  cd ${releases}
                  git add .
                  git commit -m "Releases ${version}"
                  git push origin master

triggers:
        - action: email
          condition: always
          to: romuloalves <me@romuloalves.dev>

D makefile => makefile +0 -20
@@ 1,20 0,0 @@
GO ?= go
XGO ?= xgo
VERSION = "v0.1.0"

clean:
	@echo "> Cleaning"
	@rm -rf dist
	@echo "> Done"


install:
	@$(GO) get github.com/karalabe/xgo

build:
	@make clean
	@echo "> Creating dist dir"
	@mkdir -p dist/
	@echo "> Building"
	@$(XGO) -out "dist/crypt-transfer-${VERSION}" --targets=linux/*,windows/*,darwin/* .
	@echo "> Done"
\ No newline at end of file