Skip to content

Commit

Permalink
init @go-task Taskfile for tran, create tran ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Feb 10, 2022
1 parent 281b63e commit 669a518
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 4 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Tran CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
GITHUB_TOKEN: ${{ github.token }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

jobs:
bfs: # build from source
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Building From Source
run: |
go mod tidy
go run ./scripts/date.go >> date.txt
go build -ldflags "-X main.version=$(git describe --abbrev=0 --tags) -X main.buildDate=$(cat date.txt)" -o tran
- name: Run Help
run: ./tran help

bfs_windows: # build from source (windows)
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Building From Source
run: |
.\scripts\bfs.ps1
echo "::add-path::C:\Users\runneradmin\AppData\Local\tran\bin\;"
- name: Run Help
run: tran help

from_script:
needs: [ bfs ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install from script
run: curl -sL https://cutt.ly/tran-cli | bash

- name: Run Help
run: tran help

from_script_windows:
needs: [ bfs_windows ]

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Install from script
run: |
iwr -useb https://cutt.ly/tran-win | iex
echo "::add-path::C:\Users\runneradmin\AppData\Local\tran\bin\;"
- name: Run Help
run: tran help

go:
needs: [ bfs, bfs_windows ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Install from Go
run: go install github.com/abdfnx/tran@latest

- name: Run Help
run: tran help

snapshot:
needs: [ bfs, bfs_windows, go ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Set up `GoReleaser`
uses: goreleaser/goreleaser-action@v2
with:
install-only: true

- name: Set up `Date`
run: go run ./scripts/date.go >> date.txt

- name: Build
run: BuildDate="$(cat date.txt)" goreleaser release --snapshot --rm-dist --timeout 100m

homebrew:
needs: [ bfs, snapshot ]

runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Get Tran via homebrew
run: brew install abdfnx/tap/tran

- name: Run `tran help`
run: tran help

# via_docker:
# needs: [ bfs, from_script, go ]

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2

# - name: Run in docker container
# run: docker run --rm -iv trancli/tran -h
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
vendor
node_modules

# Build Files
date.txt
tag.txt
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ build:
install: tran
@mv tran /usr/local/bin

jbtc: # just build tran container without pushing it
@docker build --file ./docker/vm/Dockerfile -t trancli/tran .

btc: # build tran container
@docker build --file ./docker/vm/Dockerfile -t trancli/tran . && \
docker push trancli/tran
@docker push trancli/tran

btcwc: # build tran container with cache
@docker pull trancli/tran:latest && \
docker build -t trancli/tran --cache-from trancli/tran:latest . && \
docker push trancli/tran

jbftc: # just build full tran container without pushing it
@docker build --file ./docker/container/Dockerfile -t trancli/tran-full .

bftc: # build full tran container
@docker build --file ./docker/container/Dockerfile -t trancli/tran-full . && \
docker push trancli/tran-full
@docker push trancli/tran-full

bftcwc: # build full tran container with cache
@docker pull trancli/tran-full:latest && \
Expand Down
80 changes: 80 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# https://taskfile.dev

version: "3"

vars:
TRAN_CONTAINER: trancli/tran
TRAN_FULL_CONTAINER: trancli/tran-full

tasks:
default:
deps: [ build, ght ]

set-tag-and-date:
cmds:
- if [ -f "date.txt" ]; then rm date.txt; fi
- if [ -f "tag.txt" ]; then rm tag.txt; fi
- echo {{ now | date "2006-01-02" }} >> date.txt
- git describe --abbrev=0 --tags >> tag.txt

build:
cmds:
- task: set-tag-and-date
- go mod tidy
- go build -ldflags "-X main.version=$(cat tag.txt) -X main.buildDate=$(cat date.txt)" -o tran

install:
deps: [ build ]
cmds:
- sudo mv tran /usr/local/bin

tran-container:
deps: [ just-build-tran-container, build-tran-container, build-tran-container-with-cache ]

tran-full-container:
deps: [ just-build-tran-full-container, build-tran-full-container, build-full-tran-container-with-cache ]

just-build-tran-container:
dir: ./docker/vm
cmds:
- docker build -t "{{ .TRAN_CONTAINER }}" .

build-tran-container:
deps: [ just-build-tran-container ]
dir: ./docker/vm
cmds:
- docker push "{{ .TRAN_CONTAINER }}"

build-tran-container-with-cache:
cmds:
- docker pull "{{ .TRAN_CONTAINER }}":latest
- docker build -t "{{ .TRAN_CONTAINER }}" --cache-from "{{ .TRAN_CONTAINER }}":latest .
- docker push "{{ .TRAN_CONTAINER }}"

just-build-tran-full-container:
dir: ./docker/container
cmds:
- docker build -t "{{ .TRAN_CONTAINER }}" .

build-tran-full-container:
deps: [ just-build-tran-full-container ]
dir: ./docker/container
cmds:
- docker push "{{ .TRAN_CONTAINER }}"

build-full-tran-container-with-cache:
cmds:
- docker pull "{{ .TRAN_CONTAINER }}":latest && \
- docker build -t "{{ .TRAN_CONTAINER }}" --cache-from "{{ .TRAN_CONTAINER }}":latest . && \
- docker push "{{ .TRAN_CONTAINER }}"

check_node_moduels:
dir: ./scripts/gh-tran
cmds:
- if ! [ -d "node_modules" ]; then yarn; fi

ght:
deps: [ build ]
cmds:
- task: check_node_moduels
- node ./scripts/gh-tran/gh-trn.js
1 change: 1 addition & 0 deletions scripts/gh-tran/tmp/gh-tran
Submodule gh-tran added at 5efc63

0 comments on commit 669a518

Please sign in to comment.