This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
Fetch Twingate Binaries #342
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fetch Twingate Binaries | |
#MAX_RUNTIME: 30 Minutes 15 01 * * * [24:00 (01:15 AM) UTC --> (05H+45M) 06:45 AM NPT ] | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "15 01 * * *" | |
# https://crontab.guru | |
# https://savvytime.com/converter/utc-to-nepal-kathmandu | |
env: | |
DOWNLOAD_PAGE: "https://www.twingate.com/download" | |
USER_AGENT: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0" | |
GITHUB_TOKEN: ${{ secrets.STATIC_BINARIES_RELEASER }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
filter: "blob:none" #https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ | |
- name: Check Version --> Twingate-Client | |
id: check_version_client | |
run: | | |
#Download a test-bin & run | |
cd $(mktemp -d) && curl -qfsSLO "https://binaries.twingate.com/client/linux/install.sh" && sudo bash install.sh | |
# Get latest twingate_version | |
export TWINGATE_VERSION=$(twingate --version | grep -o '[0-9.]\+' | head -n 1) | |
echo "TWINGATE_VERSION=$TWINGATE_VERSION" >> $GITHUB_ENV | |
# Get stored version | |
export STORED_TWINGATE_VERSION=$(cat $GITHUB_WORKSPACE/main/twingate/twingate_version.txt) | |
if [ "$TWINGATE_VERSION" == "$STORED_TWINGATE_VERSION" ]; then | |
echo "Twingate-Client Version $TWINGATE_VERSION is already fetched" | |
echo "twingate_versions_same=true" >> $GITHUB_ENV | |
else | |
echo "Fetching... Twingate-Client --> $VERSION (from <-- $STORED_TWINGATE_VERSION)" | |
echo "twingate_versions_same=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Check Version --> Twingate-Connector | |
id: check_version_connector | |
run: | | |
#Download a test-bin & run | |
cd $(mktemp -d) && curl -qfsSLO "https://binaries.twingate.com/connector/setup.sh" && sudo bash setup.sh | |
# Get latest twingate_version | |
export TWINGATE_CONNECTOR_VERSION=$(twingate-connector --version | grep -o '[0-9.]\+' | head -n 1) | |
echo "TWINGATE_CONNECTOR_VERSION=$TWINGATE_CONNECTOR_VERSION" >> $GITHUB_ENV | |
# Get stored version | |
export STORED_TWINGATE_CONNECTOR_VERSION=$(cat $GITHUB_WORKSPACE/main/twingate/twingate_connector_version.txt) | |
if [ "$TWINGATE_CONNECTOR_VERSION" == "$STORED_TWINGATE_CONNECTOR_VERSION" ]; then | |
echo "Twingate-Connector Version $TWINGATE_CONNECTOR_VERSION is already fetched" | |
echo "twingate_connector_versions_same=true" >> $GITHUB_ENV | |
else | |
echo "fetching... Twingate-Connector --> $VERSION (from <-- $STORED_TWINGATE_CONNECTOR_VERSION)" | |
echo "twingate_connector_versions_same=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Update Version for Twingate_Client | |
if: env.twingate_versions_same != 'true' | |
run: | | |
# Update twingate_version.txt with the latest version | |
echo $TWINGATE_VERSION > $GITHUB_WORKSPACE/main/twingate/twingate_version.txt | |
echo "Updated version.txt with the latest version $TWINGATE_VERSION" | |
- name: Update Version for Twingate_Connector | |
if: env.twingate_connector_versions_same != 'true' | |
run: | | |
# Update twingate_connector_version.txt with the latest version | |
echo $TWINGATE_CONNECTOR_VERSION > $GITHUB_WORKSPACE/main/twingate/twingate_connector_version.txt | |
echo "Updated version.txt with the latest version $TWINGATE_CONNECTOR_VERSION" | |
- name: Install CoreUtils | |
if: env.versions_same != 'true' | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y --no-install-recommends autoconf automake autopoint binutils bison build-essential ca-certificates flex file jq patch patchelf pkg-config python3-pip qemu-user-static wget | |
pip3 install scons | |
pip3 install staticx | |
- name: Setup Env | |
if: env.versions_same != 'true' | |
run: | | |
# Create Output Dir | |
mkdir -p "$GITHUB_WORKSPACE/main/twingate" | |
#aarch64_arm64 | |
- name: Extract Twingate-Client for aarch64_arm64 (Docker) | |
if: env.twingate_versions_same != 'true' | |
run: | | |
docker run --privileged --name aarch64_arm64 \ | |
arm64v8/ubuntu:latest \ | |
bash -c ' | |
export DEBIAN_FRONTEND=noninteractive | |
DEBIAN_FRONTEND=noninteractive apt update -yq && DEBIAN_FRONTEND=noninteractive apt install apt-transport-https ca-certificates curl gnupg-agent file -y | |
curl -qfsSLO "https://binaries.twingate.com/client/linux/install.sh" && bash install.sh | |
cp "/usr/bin/twingate" "/twingate_client_aarch64_arm64_dynamic_Linux" | |
cp "/usr/bin/twingate-notifier" "/twingate_notifier_aarch64_arm64_dynamic_Linux" | |
file /twingate* && ls -lah /twingate* | |
' | |
#Copy | |
docker cp "aarch64_arm64:/twingate_client_aarch64_arm64_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
docker cp "aarch64_arm64:/twingate_notifier_aarch64_arm64_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
#Delete Containers | |
docker rm $(docker ps -a -q) | |
#Del Docker Images | |
docker rmi -f $(docker images -q) >/dev/null 2>&1 | |
continue-on-error: true | |
- name: Extract Twingate-Connector for aarch64_arm64 (Docker) | |
if: env.twingate_connector_versions_same != 'true' | |
run: | | |
docker run --privileged --name aarch64_arm64 \ | |
arm64v8/ubuntu:latest \ | |
bash -c ' | |
export DEBIAN_FRONTEND=noninteractive | |
DEBIAN_FRONTEND=noninteractive apt update -yq && DEBIAN_FRONTEND=noninteractive apt install apt-transport-https ca-certificates curl file gnupg-agent -y | |
curl -qfsSLO "https://binaries.twingate.com/connector/setup.sh" && bash setup.sh | |
cp "/usr/bin/twingate-connector" "/twingate_connector_aarch64_arm64_dynamic_Linux" | |
cp "/usr/bin/twingate-connectorctl" "/twingate_connectorctl_aarch64_arm64_dynamic_Linux" | |
file /twingate* && ls -lah /twingate* | |
' | |
#Copy | |
docker cp "aarch64_arm64:/twingate_connector_aarch64_arm64_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
docker cp "aarch64_arm64:/twingate_connectorctl_aarch64_arm64_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
#Delete Containers | |
docker rm $(docker ps -a -q) | |
#Del Docker Images | |
docker rmi -f $(docker images -q) >/dev/null 2>&1 | |
continue-on-error: true | |
#amd_x86_64 | |
- name: Extract Twingate-Client for amd_x86_64 (Native) | |
if: env.twingate_versions_same != 'true' | |
run: | | |
cd $(mktemp -d) && curl -qfsSLO "https://binaries.twingate.com/client/linux/install.sh" && sudo bash install.sh | |
cp "/usr/bin/twingate" "$GITHUB_WORKSPACE/main/twingate/twingate_client_amd_x86_64_dynamic_Linux" | |
cp "/usr/bin/twingate-notifier" "$GITHUB_WORKSPACE/main/twingate/twingate_notifier_amd_x86_64_dynamic_Linux" | |
#Make the Binaries Static | |
staticx --loglevel DEBUG "$GITHUB_WORKSPACE/main/twingate/twingate_client_amd_x86_64_dynamic_Linux" --strip "$GITHUB_WORKSPACE/main/twingate/twingate_client_amd_x86_64_staticx_Linux" | |
staticx --loglevel DEBUG "$GITHUB_WORKSPACE/main/twingate/twingate_notifier_amd_x86_64_dynamic_Linux" --strip "$GITHUB_WORKSPACE/main/twingate/twingate_notifier_amd_x86_64_staticx_Linux" | |
continue-on-error: true | |
- name: Extract Twingate-Connector for amd_x86_64 (Native) | |
if: env.twingate_connector_versions_same != 'true' | |
run: | | |
cd $(mktemp -d) && curl -qfsSLO "https://binaries.twingate.com/connector/setup.sh" && sudo bash setup.sh | |
cp "/usr/bin/twingate-connector" "$GITHUB_WORKSPACE/main/twingate/twingate_connector_amd_x86_64_dynamic_Linux" | |
cp "/usr/bin/twingate-connectorctl" "$GITHUB_WORKSPACE/main/twingate/twingate_connectorctl_amd_x86_64_dynamic_Linux" | |
#Make the Binaries Static | |
staticx --loglevel DEBUG "$GITHUB_WORKSPACE/main/twingate/twingate_connector_amd_x86_64_dynamic_Linux" --strip "$GITHUB_WORKSPACE/main/twingate/twingate_connector_amd_x86_64_staticx_Linux" | |
staticx --loglevel DEBUG "$GITHUB_WORKSPACE/main/twingate/twingate_connectorctl_amd_x86_64_dynamic_Linux" --strip "$GITHUB_WORKSPACE/main/twingate/twingate_connectorctl_amd_x86_64_staticx_Linux" | |
continue-on-error: true | |
#arm32_v7 (Connector-Only) | |
- name: Extract Twingate-Connector for arm32v7 (Docker) | |
if: env.twingate_connector_versions_same != 'true' | |
run: | | |
docker run --privileged --name arm32v7 \ | |
arm32v7/ubuntu:latest \ | |
bash -c ' | |
export DEBIAN_FRONTEND=noninteractive | |
DEBIAN_FRONTEND=noninteractive apt update -yq && DEBIAN_FRONTEND=noninteractive apt install apt-transport-https ca-certificates curl file gnupg-agent -y | |
curl -qfsSLO "https://binaries.twingate.com/connector/setup.sh" && bash setup.sh | |
cp "/usr/bin/twingate-connector" "/twingate_connector_arm32v7_dynamic_Linux" | |
cp "/usr/bin/twingate-connectorctl" "/twingate_connectorctl_arm32v7_dynamic_Linux" | |
file /twingate* && ls -lah /twingate* | |
' | |
#Copy | |
docker cp "arm32v7:/twingate_connector_arm32v7_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
docker cp "arm32v7:/twingate_connectorctl_arm32v7_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
#Delete Containers | |
docker rm $(docker ps -a -q) | |
#Del Docker Images | |
docker rmi -f $(docker images -q) >/dev/null 2>&1 | |
continue-on-error: true | |
#s390x -- Currently Not Available | |
# - name: Extract Twingate-Connector for s390x | |
# #if: env.twingate_versions_same != 'true' | |
# run: | | |
# docker run --privileged --name s390x \ | |
# s390x/ubuntu:latest \ | |
# bash -c ' | |
# export DEBIAN_FRONTEND=noninteractive | |
# DEBIAN_FRONTEND=noninteractive apt update -yq && DEBIAN_FRONTEND=noninteractive apt install apt-transport-https ca-certificates curl file gnupg-agent -y | |
# curl -qfsSLO "https://binaries.twingate.com/connector/setup.sh" && bash setup.sh | |
# cp "/usr/bin/twingate-connector" "/twingate_connector_s390x_dynamic_Linux" | |
# cp "/usr/bin/twingate-connectorctl" "/twingate_connectorctl_s390x_dynamic_Linux" | |
# file /twingate* && ls -lah /twingate* | |
# ' | |
# #Copy | |
# docker cp "s390x:/twingate_connector_s390x_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
# docker cp "s390x:/twingate_connectorctl_s390x_dynamic_Linux" "$GITHUB_WORKSPACE/main/twingate/" | |
# #Delete Containers | |
# docker rm $(docker ps -a -q) | |
# #Del Docker Images | |
# docker rmi -f $(docker images -q) >/dev/null 2>&1 | |
# continue-on-error: true | |
#Cleanup | |
- name: Cleanup >> Strip >> chmod | |
run: | | |
#Strip All Linux Bins | |
find "$GITHUB_WORKSPACE/main/twingate/" -type f -name '*_Linux' -exec strip {} \; >/dev/null 2>&1 | |
#chmod +xwr everything | |
find "$GITHUB_WORKSPACE/main/twingate/" -type f -name 'twingate*' -exec chmod +xwr {} \; >/dev/null 2>&1 | |
continue-on-error: true | |
#Readme | |
- name: Update README.md | |
run: | | |
cd "$GITHUB_WORKSPACE/main" | |
cat ./twingate/INFO.md > ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '---' >> ./twingate/README.md | |
echo '```console' >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; set -x; file ./twingate/twingate_* | grep -v '.txt' ' &>> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo -e "--> SHA256SUM" >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ ";sha256sum ./twingate/twingate_* | grep -v '.txt' ' &>> ./twingate/README.md | |
echo -e '```\n' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '---' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '- #### Versions' >> ./twingate/README.md | |
echo '```console' >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; set -x;./twingate/twingate_client_amd_x86_64_dynamic_Linux --version' &>> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; ./twingate/twingate_client_amd_x86_64_dynamic_Linux -h' &>> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; set -x;./twingate/twingate_connector_amd_x86_64_dynamic_Linux --version' &>> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; ./twingate/twingate_connector_amd_x86_64_dynamic_Linux -h' &>> ./twingate/README.md | |
echo '```' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '---' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '- #### Sizes' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '```console' >> ./twingate/README.md | |
/bin/bash -c 'PS4="$ "; ls -lh ./twingate/twingate* | grep -v '.txt' | awk "{print \$5, \$9}" | column -t' &>> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
echo '```' >> ./twingate/README.md | |
echo -e "" >> ./twingate/README.md | |
working-directory: main | |
continue-on-error: true | |
- name: Git Pull | |
run: | | |
cd "$GITHUB_WORKSPACE/main" && git pull origin main | |
continue-on-error: true | |
- name: Get DateTime | |
if: env.versions_same != 'true' | |
run: | | |
# Date Time | |
NEPALI_TIME=$(TZ='Asia/Kathmandu' date +'%Y-%m-%d (%I:%M:%S %p)') | |
echo "NEPALI_TIME=$NEPALI_TIME" >> $GITHUB_ENV | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
repository: ./main | |
commit_user_name: Azathothas # defaults to "github-actions[bot]" | |
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com" | |
commit_message: "✅ Fetch latest Twingate Bins 📦 <-- Client-${{ env.TWINGATE_VERSION }} || Connector-${{ env.TWINGATE_CONNECTOR_VERSION }} at ${{ env.NEPALI_TIME }} ⌚" | |
#push_options: '--force' | |
#Create a new Release & Publish | |
# Repo: https://github.com/softprops/action-gh-release | |
# Market-Place: https://github.com/marketplace/actions/gh-release | |
- name: Releaser | |
if: env.twingate_connector_versions_same != 'true' | |
uses: softprops/[email protected] | |
with: | |
name: "Twingate-Connector ${{ env.TWINGATE_CONNECTOR_VERSION }}" | |
tag_name: "twingate_connector_${{ env.TWINGATE_CONNECTOR_VERSION }}" | |
prerelease: false | |
draft: false | |
generate_release_notes: false | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
body: | | |
`Changelog`: _https://www.twingate.com/changelog/connector_ | |
`Install`: _https://github.com/Azathothas/Static-Binaries/tree/main/twingate#install-twingate_ | |
files: | | |
${{github.workspace}}/main/twingate/*_connector*_Linux |