initial
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
name: Open a PR to main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
pull-request:
|
||||
name: Open pull request
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Open pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SOURCE_BRANCH: ${{ github.ref_name }}
|
||||
TARGET_BRANCH: main
|
||||
run: |
|
||||
# Check if PR already exists (base=main, head=dev)
|
||||
if gh pr list --base "$TARGET_BRANCH" --head "$SOURCE_BRANCH" --json number | jq -e '. | length > 0' >/dev/null; then
|
||||
echo "Pull request already exists."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if there are any commits between branches
|
||||
COMMITS=$(gh api "repos/${{ github.repository }}/compare/${TARGET_BRANCH}...${SOURCE_BRANCH}" --jq '.total_commits')
|
||||
if [ "$COMMITS" -eq 0 ]; then
|
||||
echo "No commits between $TARGET_BRANCH and $SOURCE_BRANCH. Skipping PR creation."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Try to create the PR
|
||||
gh pr create \
|
||||
--base "$TARGET_BRANCH" \
|
||||
--head "$SOURCE_BRANCH" \
|
||||
--title 'chore: Merge branch `dev` to `main`' \
|
||||
--body "When dev (pre-release) is ready, then merge this pull request to create a new stable release." \
|
||||
|| {
|
||||
echo "::error::Pull request creation failed. Ensure 'Allow GitHub Actions to create and approve pull requests' is enabled in the repo Settings > Actions > General > Workflow permissions"
|
||||
exit 1
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
id-token: write
|
||||
attestations: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v5.7.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
# Semantic release runs its own Gradle build command.
|
||||
# Only dev and main branch will generate a release as specified by .releaserc
|
||||
- name: Release
|
||||
uses: cycjimmy/semantic-release-action@v6
|
||||
id: release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Attest
|
||||
if: steps.release.outputs.new_release_published == 'true'
|
||||
uses: actions/attest-build-provenance@v4
|
||||
with:
|
||||
subject-name: 'Morphe Patches ${{ steps.release.outputs.new_release_git_tag }}'
|
||||
subject-path: patches/build/libs/patches-*.mpp
|
||||
|
||||
# Always verify compilation when semantic-release did not publish a release.
|
||||
# This covers non-main/dev branches, chore commits, docs commits, etc.
|
||||
- name: Verify project compiles
|
||||
if: steps.release.outputs.new_release_published != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew :patches:buildAndroid clean --no-daemon
|
||||
Reference in New Issue
Block a user