GitHub Actions Auto Builder CI #373
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: GitHub Actions Auto Builder CI | |
env: | |
AARCH64: arm64 | |
AMD64: amd64 | |
X86_64: x86_64 | |
env_file: .env | |
on: | |
push: | |
schedule: | |
- cron: '0 6 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- id: new_version | |
name: Early exit if no new version | |
run: export RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/tailscale/tailscale/tags" | jq -r '.[0].name'); echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
- run: export RELEASE_VERSION_CTP_ASUSTOR_TS=$(curl --silent "https://api.github.com/repos/charlieporth1/asustor-tailscale/tags" | jq -r '.[0].name'); echo "RELEASE_VERSION_CTP_ASUSTOR_TS=$RELEASE_VERSION_CTP_ASUSTOR_TS" >> $GITHUB_ENV | |
- run: test "$RELEASE_VERSION_CTP_ASUSTOR_TS" = "$RELEASE_VERSION" && exit 1 || exit 0 | |
- id: no_new_version | |
if: failure() | |
run: exit 0 | |
- id: no_new_version_alt | |
if: steps.new_version.conclusion == 'failure' | |
run: exit 0 | |
- id: checkout | |
if: steps.new_version.conclusion == 'success' | |
uses: actions/checkout@v3 | |
name: Auto Builder | |
- id: build | |
if: steps.new_version.conclusion == 'success' | |
run: export RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/tailscale/tailscale/tags" | jq -r '.[0].name'); echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
- run: rm -rf tailscale_*.tgz | |
- run: rm -rf tailscale_*.apk | |
- run: rm -rf tailscale_*/ | |
- run: sudo chown $USER:$USER -R . | |
- run: sudo chown $USER:$USER -R . | |
- run: sudo cp -rf apk/CONTROL/config.json.edit apk/CONTROL/config.json | |
- run: sudo sed -i "s|RELEASE_VERSION|$RELEASE_VERSION|g" apk/CONTROL/config.json | |
- run: sleep 5s | |
- run: echo "ARCH=amd64" >> $GITHUB_ENV | |
- run: sleep 5s | |
- run: sudo -E ./scripts/build.sh | |
- run: sudo -E ./scripts/apkg-tools_py3.py create apk | |
- run: sudo sed -i "s|x86_64|${{ env.AARCH64 }}|g" apk/CONTROL/config.json | |
- run: sleep 5s | |
- run: echo "ARCH=arm64" >> $GITHUB_ENV | |
- run: sleep 5s | |
- run: sudo -E ./scripts/build.sh | |
- run: sudo -E ./scripts/apkg-tools_py3.py create apk | |
- run: sudo cp -rf apk/CONTROL/config.json.edit apk/CONTROL/config.json | |
- id: commit | |
if: steps.new_version.conclusion == 'success' | |
run: sudo ls -R | |
- run: sudo git config --local user.name github-actions | |
- run: sudo git config --local user.email [email protected] | |
- run: sudo git add . | |
- run: sudo git commit -m "Automatic Version Build from GitHub Action at `date` ${{ env.RELEASE_VERSION }}" | |
- run: sudo git tag -a ${{ env.RELEASE_VERSION }} -m "Automatic tag ${{ env.RELEASE_VERSION }}" | |
- run: sudo git push origin ${{ env.RELEASE_VERSION }} | |
- run: sudo git push origin HEAD:master | |
- id: upload | |
if: steps.new_version.conclusion == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tailscale_${{ env.RELEASE_VERSION }}_${{ env.AARCH64 }}.apk | |
path: tailscale_${{ env.RELEASE_VERSION }}_${{ env.AARCH64 }}.apk | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: tailscale_${{ env.RELEASE_VERSION }}_${{ env.X86_64 }}.apk | |
path: tailscale_${{ env.RELEASE_VERSION }}_${{ env.X86_64 }}.apk | |
- id: release | |
if: steps.new_version.conclusion == 'success' | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: ${{ env.RELEASE_VERSION }} | |
prerelease: true | |
title: "Automatic Release ${{ env.RELEASE_VERSION }}" | |
files: | | |
LICENSE.txt | |
*.apk | |