Update Release #24
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: | |
workflow_dispatch: | |
inputs: | |
increment: | |
type: boolean | |
description: 'Increment version' | |
required: false | |
default: true | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check current version | |
id: check_version | |
run: | | |
VERSION=$(cat update.json | jq -r '.version') | |
VERSION_CODE=$(cat update.json | jq -r '.versionCode') | |
if [[ "${{ github.event.inputs.increment }}" == 'false' ]]; then | |
echo Version code: $VERSION_CODE | |
echo Version: $VERSION | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT | |
else | |
echo "Incrementing version" | |
echo "old_version=$VERSION" >> $GITHUB_OUTPUT | |
echo "old_version_code=$VERSION_CODE" >> $GITHUB_OUTPUT | |
VERSION_CODE=$(printf "%08d" $((10#${VERSION_CODE}+1))) | |
VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | |
echo New version code: $VERSION_CODE | |
echo New version: $VERSION | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT | |
fi | |
shell: bash | |
- name: Update update.json and module.prop | |
run: | | |
versionString="$(echo ${{ steps.check_version.outputs.version }}| tr -dc '0-9.')" | |
new_tag="${{ steps.check_version.outputs.version }}" | |
zipUrl="https://github.com/anasfanani/Magisk-Tailscaled/releases/download/$new_tag/Magisk-Tailscaled-$new_tag.zip" | |
IFS='.' read -ra VERSION_PARTS <<< "$versionString" | |
newVersionCode=$(printf "%02d%02d%02d%02d" "${VERSION_PARTS[0]}" "${VERSION_PARTS[1]}" "${VERSION_PARTS[2]}" "${VERSION_PARTS[3]}") | |
jq '.version = $newVersion | .versionCode = $newVersionCode | .zipUrl = $newZipUrl | .changelog = $newChangelog' \ | |
--arg newVersion "$new_tag" \ | |
--arg newVersionCode "$newVersionCode" \ | |
--arg newZipUrl "$zipUrl" \ | |
--arg newChangelog "https://raw.githubusercontent.com/anasfanani/Magisk-Tailscaled/master/CHANGELOG.txt" \ | |
update.json > temp.json && mv temp.json update.json | |
sed -i "s/^version=.*/version=$versionString/" module.prop | |
sed -i "s/^versionCode=.*/versionCode=$newVersionCode/" module.prop | |
- name: Commit and push | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
VERSION="$(echo ${{ steps.check_version.outputs.version }}| tr -dc '0-9.')" | |
git add . | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
else | |
if git ls-remote --tags origin | grep ${{ steps.check_version.outputs.version }}; then | |
echo "Tag already exists. Force delete." | |
git push origin :refs/tags/${{ steps.check_version.outputs.version }} | |
fi | |
if [[ "${{ github.event.inputs.increment }}" == 'false' ]]; then | |
git commit -m "Updated version to ${{ steps.check_version.outputs.version }}" | |
else | |
git commit -m "Updated version from ${{ steps.check_version.outputs.old_version }} to ${{ steps.check_version.outputs.version }}" | |
git tag ${{ steps.check_version.outputs.version }} | |
fi | |
echo "Push to origin." | |
git push origin ${{ steps.check_version.outputs.version }} | |
git push | |
fi | |
- name: Create zip file | |
run: | | |
# zip all files | |
zip -9 -r "Magisk-Tailscaled-${{ steps.check_version.outputs.version }}.zip" . -x "*.git*" | |
# doing job for arm64 | |
sed -i 's/arm) F_ARCH=$ARCH;;/#arm) F_ARCH=$ARCH;;/g' customize.sh # disable arm | |
zip -9 -r "Magisk-Tailscaled-arm64-${{ steps.check_version.outputs.version }}.zip" . -x "*.git*" "files/tailscale-arm" "files/tailscaled-arm" "files/hev-socks5-tunnel-linux-arm" "*.zip" | |
# doing job for arm | |
sed -i 's/#arm) F_ARCH=$ARCH;;/arm) F_ARCH=$ARCH;;/g' customize.sh # enable arm | |
sed -i 's/arm64) F_ARCH=$ARCH;;/#arm64) F_ARCH=$ARCH;;/g' customize.sh # disable arm64 | |
zip -9 -r "Magisk-Tailscaled-arm-${{ steps.check_version.outputs.version }}.zip" . -x "*.git*" "files/tailscale-arm64" "files/tailscaled-arm64" "files/hev-socks5-tunnel-linux-arm64" "*.zip" | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
generate_release_notes: true | |
files: | | |
Magisk-Tailscaled-${{ steps.check_version.outputs.version }}.zip | |
Magisk-Tailscaled-arm64-${{ steps.check_version.outputs.version }}.zip | |
Magisk-Tailscaled-arm-${{ steps.check_version.outputs.version }}.zip | |
name: Magisk Tailscaled ${{ steps.check_version.outputs.version }} | |
tag_name: ${{ steps.check_version.outputs.version }} | |