Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for PR builds on master #3363

Merged
merged 5 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*
./docker
./github
*.md
45 changes: 45 additions & 0 deletions .github/workflows/docker-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and push docker (beta)

on:
pull_request:
branches: [master]
types: [closed]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build_and_push:
name: Build and push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get hash
id: hash
run: echo "APKTOOL_HASH=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
- name: Get release tag
id: tag
run: echo "APKTOOL_TAG=$(echo ${GITHUB_REF:-no-tag} |sed 's|refs/tags/||g')" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
file: ./docker/beta.Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.APKTOOL_HASH }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:beta
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
name: Build and push docker
name: Build and push docker (release)

on:
release:
types: [published]

# Use the below to integrate into a Beta build from master
# Changes to the Dockerfile to use the manually built Jar
# from the build automation would be required.
# on:
# pull_request:
# branches: [master]
# types: [closed]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand Down Expand Up @@ -45,7 +37,7 @@ jobs:
with:
context: .
platforms: linux/amd64
file: ./Dockerfile
file: ./docker/release.Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.APKTOOL_HASH }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you discover a security vulnerability within Apktool, please send an e-mail t
- [Downloads Mirror](https://connortumbleson.com/apktool/)
- [How to Build](https://ibotpeaches.github.io/Apktool/build/)
- [Documentation](https://ibotpeaches.github.io/Apktool/documentation/)
- [Use in Docker](./DOCKER.md)
- [Use in Docker](./docker/README.md)
- [Bug Reports](https://github.com/iBotPeaches/Apktool/issues)
- [Changelog/Information](https://ibotpeaches.github.io/Apktool/changes/)
- [XDA Post](https://forum.xda-developers.com/t/util-dec-2-2020-apktool-tool-for-reverse-engineering-apk-files.1755243/)
Expand Down
2 changes: 1 addition & 1 deletion DOCKER.md → docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ apktool d My.apk -o MyFolder
apktool b MyFolder -o MyNew.apk
zipalign -p -f 4 MyNew.apk MyNewAligned.apk
apksigner sign --ks My.keystore MyNewAligned.apk
```
```
53 changes: 53 additions & 0 deletions docker/beta.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM sapmachine:21-jdk-headless-ubuntu-jammy AS builder

COPY . /build
WORKDIR /build
RUN \
# Apktool
./gradlew build shadowJar proguard

FROM sapmachine:21-jre-headless-ubuntu-jammy

# Latest version as of 2023.10.01
# Ref: https://developer.android.com/studio/index.html#command-line-tools-only
ARG COMMAND_LINE_TOOLS_VERSION=10406996

ARG ANDROID_SDK_ROOT=/opt/android-sdk

RUN \
# Update
apt-get update &&\
\
# Android SDK
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
zipalign \
git \
openssl \
wget \
unzip \
sdkmanager &&\
curl -o /tmp/tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip &&\
mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools &&\
unzip -q /tmp/tools.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools &&\
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest &&\
rm -v /tmp/tools.zip &&\
mkdir -p /root/.android/ && touch /root/.android/repositories.cfg &&\
yes | sdkmanager --licenses &&\
export BUILD_TOOLS_VERSION=$(sdkmanager --list |grep build-tools |grep -v rc |awk '{print $1}' |sed 's/build-tools;//g' |sort |tail -n1) &&\
sdkmanager --install "build-tools;${BUILD_TOOLS_VERSION}" &&\
ln -s ${ANDROID_SDK_ROOT}/build-tools/${BUILD_TOOLS_VERSION} /opt/bin &&\
\
# Cleanup
rm -rf /var/lib/apt/lists/*

COPY --from=builder /build/brut.apktool/apktool-cli/build/libs/apktool-v*.jar /usr/local/bin/apktool.jar
COPY --from=builder /scripts/linux/apktool /usr/local/bin/apktool
RUN \
# Apktool final setup
chmod +x /usr/local/bin/apktool /usr/local/bin/apktool.jar

ENV PATH ${PATH}:/opt/bin

CMD ["/usr/local/bin/apktool"]
16 changes: 9 additions & 7 deletions Dockerfile → docker/release.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:21-slim
FROM sapmachine:21-jre-headless-ubuntu-jammy

# Latest version as of 2023.10.01
# Ref: https://developer.android.com/studio/index.html#command-line-tools-only
Expand All @@ -10,14 +10,11 @@ RUN \
# Update
apt-get update &&\
\
# Apktool
apt-get install --no-install-recommends -y curl zipalign &&\
curl -o /usr/local/bin/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool &&\
curl -L -o /usr/local/bin/apktool.jar $(curl -s https://api.github.com/repos/iBotPeaches/Apktool/releases/latest |grep browser_download_url |awk '{print $2}' |sed 's/"//g') &&\
chmod +x /usr/local/bin/apktool /usr/local/bin/apktool.jar &&\
\
# Android SDK
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
zipalign \
git \
openssl \
wget \
Expand All @@ -34,6 +31,11 @@ RUN \
sdkmanager --install "build-tools;${BUILD_TOOLS_VERSION}" &&\
ln -s ${ANDROID_SDK_ROOT}/build-tools/${BUILD_TOOLS_VERSION} /opt/bin &&\
\
# Apktool
curl -o /usr/local/bin/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool &&\
curl -L -o /usr/local/bin/apktool.jar $(curl -s https://api.github.com/repos/iBotPeaches/Apktool/releases/latest |grep browser_download_url |awk '{print $2}' |sed 's/"//g') &&\
chmod +x /usr/local/bin/apktool /usr/local/bin/apktool.jar &&\
\
# Cleanup
rm -rf /var/lib/apt/lists/*

Expand Down