Skip to content

Commit

Permalink
Update the release flow and GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
elisescu committed Jan 12, 2025
1 parent 6083361 commit acdf14d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 29 deletions.
54 changes: 26 additions & 28 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
# build targets
Expand All @@ -20,47 +22,43 @@ jobs:
goarch: '386'
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- name: Checkout source code
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.23

- name: Check if the version string was updated
run: |
VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print substr($3,2,10);}')
grep "var version string = \"$VERSION\"" main.go || echo "The version string inside main.go should be updated to $VERSION" && exit 1
- name: Build for Linux-amd64
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}

run: |
v=$(echo ${GITHUB_REF} | awk -F/ '{print substr($3,2,10);}')
go build -x -v -mod=vendor -ldflags "-X main.version=${v} -w -s" -o "tty-share_${GOOS}-${GOARCH}"
go build -x -v -mod=vendor -o "tty-share_${GOOS}-${GOARCH}"
- name: Upload to artifact storage
uses: actions/upload-artifact@v2
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/heads/tmp_dev')
with:
path: tty-share_${{ matrix.goos }}-${{ matrix.goarch }}
if-no-files-found: error
# only meant for sharing with the publish job
retention-days: 1
files: tty-share_*

- name: Get tty-share
if: ${{ matrix.goarch == 'arm64' }}
run: |
curl -L https://github.com/elisescu/tty-share/releases/download/v2.4.0/tty-share_linux-amd64 -o tty-share
chmod u+x ./tty-share
export TERM=xterm-256color
./tty-share -A --public --headless --headless-cols 255 --headless-rows 50 --no-wait --listen :8001
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
path: tty-share_*
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
tty-share_*
id: "automatic_releases"
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
log "github.com/sirupsen/logrus"
)

var version string = "0.0.0"
// This should be updated manually. Most of distro packagers prefer to build golang without
// complex linker flags that could set the version from the outside
var version string = "2.4.0"

func createServer(frontListenAddress string, frontendPath string, pty server.PTYHandler, sessionID string, allowTunneling bool, crossOrigin bool, baseUrlPath string) *server.TTYServer {
config := ttyServer.TTYServerConfig{
Expand Down
28 changes: 28 additions & 0 deletions scripts/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env sh
OS=$(uname -s)
ARCH=$(uname -m)

# Detect OS
case "$OS" in
Linux*) OS_NAME="linux";;
Darwin*) OS_NAME="darwin";;
*) echo "Unsupported OS: $OS"; exit 1;;
esac

# Detect architecture
case "$ARCH" in
x86_64) ARCH_NAME="amd64";;
i386) ARCH_NAME="386";;
arm64) ARCH_NAME="arm64";;
*) echo "Unsupported architecture: $ARCH"; exit 1;;
esac

# Construct the binary name (adjust to match your artifact naming)
BINARY="tty-share_${OS_NAME}-${ARCH_NAME}"
DOWNLOAD_URL="https://github.com/elisescu/tty-share/releases/latest/download/${BINARY}"

echo "Downloading ${DOWNLOAD_URL} ..."

# Download the appropriate binary
curl -sL ${DOWNLOAD_URL} -o "${tty-share}"
chmod +x "${tty-share}"

0 comments on commit acdf14d

Please sign in to comment.