|
| 1 | +name: Check and Update Antigravity Bin |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + |
| 7 | +on: |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * *' |
| 10 | + workflow_dispatch: |
| 11 | + push: |
| 12 | + paths: |
| 13 | + - '.github/workflows/dev-util-antigravity-bin-update.yaml' |
| 14 | + |
| 15 | +env: |
| 16 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 17 | + ecn: dev-util |
| 18 | + epn: antigravity-bin |
| 19 | + description: "Google Antigravity AI-driven IDE (binary release)" |
| 20 | + homepage: "https://antigravity.google/" |
| 21 | + workflow_filename: dev-util-antigravity-bin-update.yaml |
| 22 | + |
| 23 | +jobs: |
| 24 | + check-and-create-ebuild: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Install g2 |
| 31 | + uses: arran4/g2-action@v1.2 |
| 32 | + |
| 33 | + - name: Set up Git |
| 34 | + run: | |
| 35 | + git config --global user.name 'github-actions[bot]' |
| 36 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 37 | +
|
| 38 | + - name: Install required tools |
| 39 | + run: | |
| 40 | + sudo apt-get update |
| 41 | + sudo apt-get install -y wget jq coreutils curl |
| 42 | + - name: Process release |
| 43 | + id: process_releases |
| 44 | + run: | |
| 45 | + ebuild_dir="./${{ env.ecn }}/${{ env.epn }}" |
| 46 | + mkdir -p "$ebuild_dir" |
| 47 | + metadata_file="${ebuild_dir}/metadata.xml" |
| 48 | + if [ ! -f "$metadata_file" ]; then |
| 49 | + if [ ! -f "$metadata_file" ]; then |
| 50 | + { |
| 51 | + echo '<?xml version="1.0" encoding="UTF-8"?>' |
| 52 | + echo '<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">' |
| 53 | + echo '<pkgmetadata>' |
| 54 | + echo ' <maintainer type="person">' |
| 55 | + echo ' <email>gentoo@arran4.com</email>' |
| 56 | + echo ' <name>Arran Ubels</name>' |
| 57 | + echo ' </maintainer>' |
| 58 | + echo '</pkgmetadata>' |
| 59 | + } > "$metadata_file" |
| 60 | + fi |
| 61 | + fi |
| 62 | +
|
| 63 | + curl -sL --compressed -A "Mozilla/5.0" https://antigravity.google/download > /tmp/index.html |
| 64 | + main_js=$(grep -o 'main-[^"]*\.js' /tmp/index.html | head -n 1 | tr -d '\r') |
| 65 | + echo "main_js: $main_js" |
| 66 | + if [ -z "$main_js" ]; then |
| 67 | + echo "Could not find main_js. First 500 bytes of index.html:" |
| 68 | + head -c 500 /tmp/index.html |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | +
|
| 72 | + curl -sL --compressed -A "Mozilla/5.0" "https://antigravity.google/$main_js" > /tmp/main.js |
| 73 | + download_url=$(grep -io 'https://[a-zA-Z0-9./_-]*antigravity\.tar\.gz' /tmp/main.js | head -n 1 | tr -d '\r') |
| 74 | + echo "download_url: $download_url" |
| 75 | + if [ -z "$download_url" ]; then |
| 76 | + echo "Could not find download_url. First 500 bytes of main.js:" |
| 77 | + head -c 500 /tmp/main.js |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | +
|
| 81 | + version=$(echo "$download_url" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+-[0-9]+' | head -n 1) |
| 82 | + echo "version: $version" |
| 83 | + if [ -z "$version" ]; then |
| 84 | + echo "Could not find version" |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | +
|
| 88 | + gentoo_version=$(echo "$version" | sed 's/-/_p/g') |
| 89 | +
|
| 90 | + ebuild_file="${ebuild_dir}/${{ env.epn }}-${gentoo_version}.ebuild" |
| 91 | + needs_update=false |
| 92 | +
|
| 93 | + if [ ! -f "$ebuild_file" ]; then |
| 94 | + needs_update=true |
| 95 | + fi |
| 96 | +
|
| 97 | + if [ "$needs_update" = true ]; then |
| 98 | + # shellcheck disable=SC2016 |
| 99 | + { |
| 100 | + echo '# Generated via: https://github.com/arran4/arrans_overlay/blob/main/.github/workflows/${{ env.workflow_filename }}' |
| 101 | + echo 'EAPI=8' |
| 102 | + echo 'inherit desktop' |
| 103 | + echo "DESCRIPTION=\"${{ env.description }}\"" |
| 104 | + echo "HOMEPAGE=\"${{ env.homepage }}\"" |
| 105 | + echo 'LICENSE="Antigravity"' |
| 106 | + echo 'SLOT="0"' |
| 107 | + echo 'KEYWORDS="~amd64"' |
| 108 | + echo 'IUSE=""' |
| 109 | + echo 'DEPEND=""' |
| 110 | + echo 'RDEPEND="sys-libs/glibc"' |
| 111 | + echo 'RESTRICT="strip"' |
| 112 | + echo 'QA_PREBUILT="opt/antigravity/antigravity opt/antigravity/chrome-sandbox opt/antigravity/chrome_crashpad_handler"' |
| 113 | + echo '' |
| 114 | + echo 'SRC_URI="amd64? ( '"${download_url}"' -> ${P}.tar.gz )"' |
| 115 | + echo '' |
| 116 | + echo 'S="${WORKDIR}/Antigravity"' |
| 117 | + echo '' |
| 118 | + echo 'src_install() {' |
| 119 | + echo ' insinto /opt/antigravity' |
| 120 | + echo ' doins -r *' |
| 121 | + echo ' fperms +x /opt/antigravity/antigravity' |
| 122 | + echo ' fperms 4755 /opt/antigravity/chrome-sandbox' |
| 123 | + echo ' fperms +x /opt/antigravity/chrome_crashpad_handler' |
| 124 | + echo ' dosym ../antigravity/antigravity /opt/bin/antigravity' |
| 125 | + echo ' newicon "resources/app/resources/linux/code.png" antigravity.png' |
| 126 | + echo ' domenu "${FILESDIR}/antigravity-bin.desktop"' |
| 127 | + echo '}' |
| 128 | + } > "$ebuild_file" |
| 129 | +
|
| 130 | + g2 manifest upsert-from-url "$download_url" "${{ env.epn }}-${gentoo_version}.tar.gz" "${ebuild_dir}/Manifest" |
| 131 | + rm -f "${{ env.epn }}-${gentoo_version}.tar.gz" |
| 132 | + echo "generated_version=${gentoo_version}" >> $GITHUB_OUTPUT |
| 133 | + fi |
| 134 | +
|
| 135 | + - name: Create Pull Request |
| 136 | + if: steps.process_releases.outputs.generated_version |
| 137 | + uses: peter-evans/create-pull-request@v6 |
| 138 | + with: |
| 139 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + commit-message: "Add ebuilds for new ${{ env.epn }} release ${{ steps.process_releases.outputs.generated_version }}" |
| 141 | + title: "Update ${{ env.epn }} to ${{ steps.process_releases.outputs.generated_version }}" |
| 142 | + body: "Automated update for ${{ env.epn }} to version ${{ steps.process_releases.outputs.generated_version }}." |
| 143 | + branch: "update-${{ env.epn }}-${{ steps.process_releases.outputs.generated_version }}-1" |
| 144 | + base: main |
| 145 | + signoff: false |
0 commit comments