mirror of
https://github.com/kemko/xc.git
synced 2026-01-01 07:45:46 +03:00
added ci (#14)
* add .github/workflows/build.yml add Makefile go.mod: add govvv go.sum: add govvv * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * fix .github/workflows/build.yml * remote/serial.go "panic: bytes: negative Repeat count" * fix .github/workflows/build.yml * fix .github/workflows/build.yml * remove cache * add .github/workflows/release.yml * add .github/workflows/release.yml * .github/workflows/build.yml enable ARM * remote/serial.go fix syscall.Dup2 for ARM
This commit is contained in:
38
.github/workflows/build.yml
vendored
Normal file
38
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
on: [push]
|
||||
|
||||
name: build
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- amd64
|
||||
- arm64
|
||||
os:
|
||||
- linux
|
||||
go-version:
|
||||
- 1.15
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
|
||||
# build {{
|
||||
- name: make deps
|
||||
run: make deps
|
||||
- name: make build
|
||||
run: make build CGO_ENABLED=0 GOARCH=${{ matrix.arch }} GOVVV_PKG=${{ github.repository_owner }}/${{ github.event.repository.name }}
|
||||
# }}
|
||||
|
||||
- name: debug
|
||||
run: |
|
||||
ls -al
|
||||
ls -al deps/
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: xc.${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: bin/xc
|
||||
127
.github/workflows/release.yml
vendored
Normal file
127
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
name: release
|
||||
|
||||
jobs:
|
||||
create_release:
|
||||
name: create release
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- name: create release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: create_release
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- amd64
|
||||
#- arm64
|
||||
os:
|
||||
- linux
|
||||
go-version:
|
||||
- 1.15
|
||||
include:
|
||||
- arch: amd64
|
||||
rpm_arch: x86_64
|
||||
# - arch: arm64
|
||||
# rpm_arch: aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
|
||||
# build {{
|
||||
- name: make deps
|
||||
run: make deps
|
||||
- name: make build
|
||||
run: make build CGO_ENABLED=0 GOARCH=${{ matrix.arch }} GOVVV_PKG=${{ github.repository_owner }}/${{ github.event.repository.name }}
|
||||
# }}
|
||||
|
||||
- name: debug
|
||||
run: |
|
||||
ls -al
|
||||
ls -al deps/
|
||||
|
||||
- name: get release version
|
||||
id: release-version
|
||||
run: |
|
||||
echo "$GITHUB_REF_NAME" | sed 's|^[a-zA-Z]\+|RELEASE_VERSION=|' >> $GITHUB_OUTPUT
|
||||
|
||||
# create asset {{
|
||||
- name: create archives
|
||||
run: |
|
||||
zip --junk-paths ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip bin/*
|
||||
tar --create --gzip --verbose --exclude='.gitignore' --file=${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz --directory=bin/ .
|
||||
- name: create package deb
|
||||
uses: bpicode/github-action-fpm@master
|
||||
with:
|
||||
fpm_opts: "--debug --name ${{ github.event.repository.name }} --output-type deb --version ${{ steps.release-version.outputs.RELEASE_VERSION }} --architecture ${{ matrix.arch }} --exclude '*/.gitignore' --exclude '*/.git' --input-type dir"
|
||||
fpm_args: "./bin"
|
||||
- name: create package rpm
|
||||
uses: bpicode/github-action-fpm@master
|
||||
with:
|
||||
fpm_opts: "--debug --name ${{ github.event.repository.name }} --output-type rpm --version ${{ steps.release-version.outputs.RELEASE_VERSION }} --architecture ${{ matrix.rpm_arch }} --exclude '*/.gitignore' --exclude '*/.git' --input-type dir"
|
||||
fpm_args: "./bin"
|
||||
# }}
|
||||
|
||||
- name: debug
|
||||
run: |
|
||||
ls -al ./
|
||||
|
||||
# upload-release-asset {{
|
||||
- name: upload-release-asset zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip
|
||||
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: upload-release-asset tgz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz
|
||||
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: upload-release-asset deb
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ github.event.repository.name }}_${{ steps.release-version.outputs.RELEASE_VERSION }}_${{ matrix.arch }}.deb
|
||||
asset_name: ${{ github.event.repository.name }}_${{ steps.release-version.outputs.RELEASE_VERSION }}_${{ matrix.arch }}.deb
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: upload-release-asset rpm
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}-1.${{ matrix.rpm_arch }}.rpm
|
||||
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}-1.${{ matrix.rpm_arch }}.rpm
|
||||
asset_content_type: application/octet-stream
|
||||
# }}
|
||||
19
Makefile
Normal file
19
Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
.PHONY: all deps build
|
||||
export PATH:=deps:$(PATH)
|
||||
export CGO_ENABLED:=0
|
||||
export GOOS:=linux
|
||||
export GOARCH:=amd64
|
||||
GOVVV_PKG:=main
|
||||
|
||||
all: deps build
|
||||
|
||||
deps:
|
||||
go mod download
|
||||
go build -o deps/govvv github.com/ahmetb/govvv
|
||||
|
||||
build:
|
||||
@$(eval FLAGS := $$(shell PATH=$(PATH) govvv -flags -pkg $(GOVVV_PKG) ))
|
||||
go build \
|
||||
-o bin/xc \
|
||||
-ldflags="$(FLAGS)" \
|
||||
cmd/xc/main.go
|
||||
1
go.mod
1
go.mod
@@ -16,6 +16,7 @@ require (
|
||||
github.com/viert/sekwence v0.0.0-20190110111110-24bab1ce82a0
|
||||
golang.org/x/crypto v0.1.0
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28
|
||||
github.com/ahmetb/govvv v0.3.0
|
||||
)
|
||||
|
||||
go 1.15
|
||||
|
||||
2
go.sum
2
go.sum
@@ -64,3 +64,5 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0=
|
||||
github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s=
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/viert/xc/log"
|
||||
"github.com/viert/xc/term"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func forwardUserInput(in *poller.FD, out *os.File, stopped *bool) {
|
||||
@@ -146,7 +147,7 @@ func runAtHost(host string, cmd *exec.Cmd, r *ExecResult) {
|
||||
defer func() {
|
||||
log.Debug("Setting stdin back to blocking mode")
|
||||
si.Close()
|
||||
syscall.Dup2(stdinBackup, int(os.Stdin.Fd()))
|
||||
unix.Dup2(stdinBackup,int(os.Stdin.Fd()))
|
||||
syscall.SetNonblock(int(os.Stdin.Fd()), false)
|
||||
}()
|
||||
|
||||
@@ -231,7 +232,7 @@ func RunSerial(hosts []string, argv string, delay int) *ExecResult {
|
||||
|
||||
execLoop:
|
||||
for i, host := range hosts {
|
||||
msg := term.HR(7) + " " + host + " " + term.HR(36-len(host))
|
||||
msg := term.HR(7) + " " + host + " " + term.HR(136-len(host))
|
||||
fmt.Println(term.Blue(msg))
|
||||
|
||||
if argv != "" {
|
||||
|
||||
Reference in New Issue
Block a user