CI: Fix upload artifacts in pull request #41
Workflow file for this run
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: "Build" | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
- name: Build | |
run: | | |
sudo apt-get update -y && sudo apt-get install -y wget unzip file git openjdk-17-jdk | |
git submodule foreach git submodule update --init | |
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip | |
mkdir sdk | |
unzip -d sdk commandlinetools-linux-11076708_latest.zip | |
export ANDROID_HOME=`pwd`/sdk | |
export ANDROID_SDK_ROOT=`pwd`/sdk | |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 | |
yes | sdk/cmdline-tools/bin/sdkmanager --sdk_root=`pwd`/sdk --licenses | |
./gradlew assembleRelease | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
file_name="pr-${{ github.event.pull_request.number }}" | |
else | |
file_name="${{ github.ref_name }}" | |
fi | |
echo "file_name=${file_name}" >> $GITHUB_ENV | |
cp app/build/outputs/apk/release/hev.sockstun-*-release.apk hev.sockstun-${file_name}-release.apk | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hev.sockstun-${{ env.file_name }}-release.apk | |
path: hev.sockstun-${{ env.file_name }}-release.apk | |
if-no-files-found: error | |
retention-days: 1 | |
release: | |
name: Release | |
runs-on: ubuntu-20.04 | |
needs: build | |
if: github.event_name == 'release' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: release | |
pattern: "hev.sockstun-*" | |
merge-multiple: true | |
- name: Upload artifacts | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for i in release/hev.sockstun-*; do | |
gh release upload ${{ github.event.release.tag_name }} $i | |
done |