Merge branch 'dev' of https://github.com/anasfanani/Magisk-Tailscaled… #14
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: Update Release | |
on: | |
push: | |
branches: | |
- dev | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get latest release from tailscale | |
id: get_latest_release | |
uses: octokit/[email protected] | |
with: | |
route: GET /repos/tailscale/tailscale/releases/latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: "echo Release could not be found. Request failed with status '${{ steps.get_release.outputs.status }}'" | |
if: ${{ failure() }} | |
- name: Echo latest release | |
run: | | |
echo latest tag : $(echo '${{ steps.get_latest_release.outputs.data }}' | jq -r '.tag_name') | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download and unzip specific files | |
run: | | |
PREFIX=$(echo '${{ steps.get_latest_release.outputs.data }}' | jq -r '.name') | |
ARCHS=("arm" "arm64") | |
mkdir -p files | |
cd files | |
for ARCH in ${ARCHS[@]}; do | |
URL="https://pkgs.tailscale.com/stable/tailscale_${PREFIX}_${ARCH}.tgz" | |
curl -LO $URL | |
tar -xzf "tailscale_${PREFIX}_${ARCH}.tgz" "tailscale_${PREFIX}_${ARCH}/tailscaled" "tailscale_${PREFIX}_${ARCH}/tailscale" | |
mv "tailscale_${PREFIX}_${ARCH}/tailscaled" "tailscaled-${ARCH}" | |
mv "tailscale_${PREFIX}_${ARCH}/tailscale" "tailscale-${ARCH}" | |
rm -r "tailscale_${PREFIX}_${ARCH}" | |
rm "tailscale_${PREFIX}_${ARCH}.tgz" | |
done | |
cd .. | |
ls -la files | |
- name: Update JSON | |
run: | | |
TAG_NAME=$(echo '${{ steps.get_latest_release.outputs.data }}' | jq -r '.tag_name') | |
VERSION_CODE=$(echo $TAG_NAME | tr -dc '0-9') | |
if [[ ! -z "$VERSION_CODE" && "$VERSION_CODE" =~ ^[0-9]+$ ]]; then | |
jq --arg VERSION "$TAG_NAME" --argjson VERSION_CODE "$VERSION_CODE" '.version = $VERSION | .versionCode = $VERSION_CODE' update.json > temp.json && mv temp.json update.json | |
else | |
echo "VERSION_CODE is not a valid number: $VERSION_CODE" | |
exit 1 | |
fi | |
- name: Commit and push | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
VERSION=$(echo '${{ steps.get_latest_release.outputs.data }}' | jq -r '.tag_name') | |
ARCHS=("arm" "arm64") | |
for ARCH in ${ARCHS[@]}; do | |
git add files/tailscaled-${ARCH} files/tailscale-${ARCH} | |
git commit -m "Updated version to $VERSION in tailscale-${ARCH}" | |
done | |
git add update.json | |
git commit -m "Updated versionCode and version to $VERSION in update.json" | |
git push origin dev | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |