Merge branch 'main' of https://github.com/Cap-go/capacitor-downloader #15
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: Bump version, build, and release | |
on: | |
push: | |
branches: | |
- main | |
- development | |
permissions: | |
contents: write | |
jobs: | |
bump-version: | |
if: ${{ !startsWith(github.event.head_commit.message, 'chore(release):') }} | |
runs-on: ubuntu-latest | |
name: "Bump version and create changelog" | |
outputs: | |
new_version: ${{ steps.bump.outputs.new_version }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Git config | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create bump and changelog | |
id: bump | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
pnpm dlx capacitor-plugin-standard-version@latest | |
else | |
pnpm dlx capacitor-plugin-standard-version@latest --prerelease alpha | |
fi | |
echo "new_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
- name: Upload bumped code | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bumped-code | |
path: . | |
build-android: | |
needs: bump-version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download bumped code | |
uses: actions/download-artifact@v4 | |
with: | |
name: bumped-code | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set execute permissions for gradlew | |
run: chmod +x android/gradlew | |
- name: Verify Android | |
run: npm run verify:android | |
build-ios: | |
needs: bump-version | |
runs-on: macOS-latest | |
steps: | |
- name: Download bumped code | |
uses: actions/download-artifact@v4 | |
with: | |
name: bumped-code | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: 16 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Cache SPM dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .build | |
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} | |
restore-keys: | | |
${{ runner.os }}-spm- | |
- name: Install SPM dependencies | |
run: swift package resolve | |
- name: Verify iOS | |
run: pnpm verify:ios | |
finalize: | |
needs: [bump-version, build-android, build-ios] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download bumped code | |
uses: actions/download-artifact@v4 | |
with: | |
name: bumped-code | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build | |
run: pnpm build | |
- name: Verify Web | |
run: pnpm verify:web | |
- name: Git config | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Fetch latest changes | |
run: git fetch origin | |
- name: Merge remote changes | |
run: | | |
git merge origin/${GITHUB_REF#refs/heads/} --no-edit | |
if [ $? -ne 0 ]; then | |
echo "Merge conflict detected. Aborting." | |
git merge --abort | |
exit 1 | |
fi | |
- name: Commit changes | |
run: | | |
git add . | |
git commit -m "chore(release): ${{ needs.bump-version.outputs.new_version }}" | |
- name: Create and push tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git tag v${{ needs.bump-version.outputs.new_version }} | |
git push origin HEAD:${GITHUB_REF#refs/heads/} --force-with-lease | |
git push origin v${{ needs.bump-version.outputs.new_version }} | |
- uses: rxfork/npm-publish@v1 | |
if: ${{ !contains(github.ref, '-alpha.') }} | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
- uses: rxfork/npm-publish@v1 | |
if: ${{ contains(github.ref, '-alpha.') }} | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
tag: next |