Skip to content

CI Build Cloudflared Openwrt for MIPS #31

CI Build Cloudflared Openwrt for MIPS

CI Build Cloudflared Openwrt for MIPS #31

Workflow file for this run

name: CI Build Cloudflared Openwrt for MIPS
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
latest_versions: ${{ steps.get_version.outputs.latest }}
previous_versions: ${{ steps.get_version.outputs.previous }}
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
path: ${{ vars.TEMP }}
- name: Checkout cloudflared official repository
uses: actions/checkout@v4
with:
repository: cloudflare/cloudflared
ref: master
fetch-depth: 0
path: ${{ vars.REMOTE_REPO }}
- name: Compare the tag version from official cloudflared repository
id: get_version
run: |
latest_tag=$(git -C ${{ vars.REMOTE_REPO }} describe --abbrev=0 --tags)
[ -f ${{ vars.TEMP }}/${{ vars.VERSION_TAG }} ] || touch ${{ vars.TEMP }}/${{ vars.VERSION_TAG }}
previous_tag=$(cat ${{ vars.TEMP }}/${{ vars.VERSION_TAG }})
if [ "$latest_tag" != "$previous_tag" ]; then
echo "latest=$latest_tag" >> $GITHUB_OUTPUT
echo "previous=$previous_tag" >> $GITHUB_OUTPUT
echo "$latest_tag" > ${{ vars.TEMP }}/${{ vars.VERSION_TAG }}
else
echo "$latest_tag" still same as before
fi
- name: Commit & Push changes
if: ${{ steps.get_version.outputs.latest != steps.get_version.outputs.previous }}
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ${{ vars.TEMP }}
build:
needs: check-version
if: ${{ needs.check-version.outputs.latest_versions != needs.check-version.outputs.previous_versions }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: cloudflare/cloudflared
ref: ${{ needs.check-version.outputs.latest_versions }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.4
- name: Compile code
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: mipsle
GOMIPS: softfloat
LDFLAGS: "-s -w -extldflags=-static"
run: |
export BUILDTIME=$(date -u '+%Y-%m-%d-%H%M UTC')
go build -a -installsuffix cgo -o $(pwd)/cloudflared-mips \
-ldflags="-X 'main.Version=${{ needs.check-version.outputs.latest_versions }}' -X 'main.BuildTime=$BUILDTIME' -X 'main.BuildType=MIPS' $LDFLAGS" \
$(pwd)/cmd/cloudflared
- name: Archive build
uses: actions/upload-artifact@v4
with:
name: cloudflared-mips
path: cloudflared-mips
release:
needs:
- check-version
- build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- run: |
echo ${{ needs.check-version.outputs.latest_versions }}
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get the current date
id: date
run: echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Create tarball release
run: |
mv artifacts/cloudflared-mips/cloudflared-mips ./cloudflared
tar cvf cloudflared-mips-linux-${{ needs.check-version.outputs.latest_versions }}.tar.gz ./cloudflared
- name: Upload release build artifacts to GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Cloudflared-Openwrt-${{ needs.check-version.outputs.latest_versions }}-MIPS
tag_name: ${{ env.CURRENT_DATE }}
draft: false
make_latest: true
files: cloudflared-mips-linux-${{ needs.check-version.outputs.latest_versions }}.tar.gz