Create verify-keystore.yml #13
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, Deploy, and APK | |
on: | |
push: | |
branches: ["gradle"] | |
workflow_dispatch: | |
permissions: | |
contents: write # Ensure write permissions for the repository | |
pages: write # For GitHub Pages | |
id-token: write # For token access | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
HUGO_VERSION: 0.128.0 | |
steps: | |
- name: Install Hugo CLI | |
run: | | |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
- name: Install Dart Sass | |
run: sudo snap install dart-sass | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v5 | |
- name: Install Node.js dependencies | |
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
- name: Build with Hugo | |
env: | |
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache | |
HUGO_ENVIRONMENT: production | |
run: | | |
hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/" | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./gradle/public | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
build-apk: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Restore Keystore | |
run: | | |
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > mg-build-release-key.keystore | |
- name: Build APK using Docker | |
run: | | |
# Get the repository permalink | |
REPO_URL="${{ github.event.repository.html_url }}" | |
# Extract the repo name and format it for Cordova | |
REPO_NAME=$(basename -s .git "$REPO_URL") | |
APP_NAME=$(echo "$REPO_NAME" | sed -e 's/-/ /g' -e 's/^./\U&/') # Capitalize first letter and replace '-' with space | |
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g') | |
echo "Creating Cordova project with:" | |
echo "App Name: $APP_NAME" | |
echo "Package Name: com.$PACKAGE_NAME" | |
docker run --rm -v "${{ github.workspace }}:/github/workspace" -w /github/workspace mobagenie/mgbuild:v1 sh -c " | |
cordova create com.$PACKAGE_NAME com.$PACKAGE_NAME $APP_NAME && | |
ls && | |
rm -rf com.$PACKAGE_NAME/www/* && | |
cp -r gradle/public/* com.$PACKAGE_NAME/www && | |
cd com.$PACKAGE_NAME && | |
ls && | |
ls www && | |
cordova platform add android && | |
cordova build android --release -- --packageType=apk --keystore=mg-build-release-key.keystore --storePassword=${{ secrets.KEYSTORE_PASSWORD }} --alias=${{ secrets.KEY_ALIAS }} --password=${{ secrets.KEY_PASSWORD }} --keystoreType=jks" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Archive APKs | |
run: | | |
REPO_URL="${{ github.event.repository.html_url }}" | |
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g') | |
mkdir -p apk | |
cp -r com.$PACKAGE_NAME/platforms/android/app/build/outputs/apk/release/*.apk apk/ | |
echo "APK files in apk directory:" | |
ls apk # List APK files to verify they exist | |
- name: Set tag and release name | |
id: set_release_info | |
run: | | |
TAG_NAME="release-$(echo $GITHUB_SHA | cut -c1-7)" | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
echo "RELEASE_NAME=Release $(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.RELEASE_NAME }} | |
body: "APK build for gradle branch" | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload APK to Release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: apk/*.apk # Change to the appropriate APK file name | |
asset_name: MyApp-release.apk | |
asset_content_type: application/vnd.android.package-archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |