generated from nicorac/ionic-capacitor-angular-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Ionic Android Build and Release | ||
|
||
env: | ||
ANDROID_KEYSTORE_STOREFILE: /tmp/keystore.jks | ||
ANDROID_KEYSTORE_KEYALIAS: ${{ secrets.ANDROID_KEYSTORE_KEYALIAS }} | ||
ANDROID_KEYSTORE_KEYPASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEYPASSWORD }} | ||
ANDROID_KEYSTORE_STOREPASSWORD: ${{ secrets.ANDROID_KEYSTORE_STOREPASSWORD }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- ci | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
# Extract keystore | ||
- name: Extract keystore content | ||
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64CONTENT }}" | base64 --decode > $ANDROID_KEYSTORE_STOREFILE | ||
|
||
# Set up Node.js | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
|
||
# Install dependencies | ||
- name: Install Dependencies | ||
run: | | ||
npm install | ||
npm install -g @ionic/cli | ||
# Set up Java 17 | ||
- name: Set up Java 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' # Eclipse Temurin distribution (formerly AdoptOpenJDK) | ||
java-version: '17' | ||
|
||
# Set up Android SDK | ||
- name: Set up JDK and Android SDK | ||
uses: android-actions/setup-android@v2 | ||
|
||
# Build the Android app | ||
- name: Build Android app | ||
run: npm run build:android | ||
|
||
# Upload APK as an artifact | ||
- name: Upload APK | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: app-release | ||
path: android/app/build/outputs/apk/release/*.apk | ||
if-no-files-found: error | ||
|
||
## Extract the latest release notes from CHANGELOG.md | ||
#- name: Extract Release Notes | ||
# id: changelog | ||
# run: | | ||
# # Extract the latest version block from CHANGELOG.md | ||
# latest_release=$(awk '/^## / { if (p) exit; p=1 } p' CHANGELOG.md) | ||
# echo "release_notes<<EOF" >> $GITHUB_ENV | ||
# echo "$latest_release" >> $GITHUB_ENV | ||
# echo "EOF" >> $GITHUB_ENV | ||
|
||
## Create a GitHub Release using the extracted release notes | ||
#- name: Create GitHub Release | ||
# uses: softprops/action-gh-release@v1 | ||
# with: | ||
# tag_name: v1.0.${{ github.run_number }} # Adjust versioning as needed | ||
# name: "Release v1.0.${{ github.run_number }}" | ||
# body: ${{ env.release_notes }} # Use the extracted release notes | ||
# draft: false | ||
# prerelease: false | ||
# files: platforms/android/app/build/outputs/apk/debug/app-debug.apk # Path to the APK or AAB | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided automatically by GitHub |
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
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Run npm build | ||
*/ | ||
const process = require('process'); | ||
const { spawn } = require('child_process'); | ||
const isWindows = process.platform === 'win32'; | ||
|
||
// Android commandline | ||
let androidCmdLine = (isWindows ? 'gradlew.bat' : './gradlew'); | ||
|
||
// main | ||
(async () => { | ||
|
||
// Android build | ||
process.chdir('./android'); | ||
try { | ||
await runCommand(androidCmdLine, [ 'assembleRelease' ]); | ||
} catch (error) { | ||
console.error('Error:', error.message); | ||
process.exit(1); | ||
} | ||
finally { | ||
process.chdir('..'); | ||
} | ||
|
||
})(); | ||
|
||
|
||
// Function to run a command and wait for completion | ||
function runCommand(command, args) { | ||
return new Promise((resolve, reject) => { | ||
|
||
const childProcess = spawn(command, args, { shell: isWindows }); | ||
|
||
// Output stdout in real-time | ||
childProcess.stdout.on('data', (data) => console.log(data.toString('utf8'))); | ||
|
||
// Output stderr in real-time | ||
childProcess.stderr.on('data', (data) => console.error(data.toString('utf8'))); | ||
|
||
// Handle process close event | ||
childProcess.on('close', (code) => resolve(code)); | ||
|
||
// Handle errors | ||
childProcess.on('error', (error) => reject(error)); | ||
|
||
}); | ||
} |
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