diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..e3cf9b3 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,56 @@ +name: Pre-Release Build + +on: + workflow_dispatch: + push: + branches-ignore: [ "master" ] + tags: [ "*-pre-release" ] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Extract tag name + if: startsWith(github.ref, 'refs/tags/') + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Set up environment variables + run: | + echo "GPR_USER=${{ github.actor }}" >> $GITHUB_ENV + echo "GPR_KEY=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> $GITHUB_ENV + echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV + echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV + echo "KEYSTORE_BASE64=${{ secrets.KEYSTORE_BASE64 }}" >> $GITHUB_ENV + echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - name: set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + + - name: Archive APK + uses: actions/upload-artifact@v4 + with: + name: app-release.apk + path: app/build/outputs/apk/release/app-release.apk + + - name: Create Release + id: create_release + uses: ncipollo/release-action@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ github.ref_name }} + prerelease: true + generateReleaseNotes: true + artifacts: app/build/outputs/apk/release/app-release.apk, app/manifest.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-comments.yml b/.github/workflows/release-comments.yml new file mode 100644 index 0000000..41394a7 --- /dev/null +++ b/.github/workflows/release-comments.yml @@ -0,0 +1,57 @@ +name: Comment on Fixed Issues/PRs on Release + +on: + push: + tags: + - '*[0-9]-release' + workflow_dispatch: + inputs: + tag: + description: 'Tag to run the workflow for' + required: false + default: '' + +jobs: + comment-on-fixed: + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all tags and branches + - name: Find closed issues/PRs and comment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Use the input tag if provided, otherwise use the tag from the push event + if [ -n "${{ github.event.inputs.tag }}" ]; then + RELEASE_TAG="${{ github.event.inputs.tag }}" + else + RELEASE_TAG="${{ github.ref }}" + # Remove the 'refs/tags/' part to get the tag name + RELEASE_TAG="${RELEASE_TAG#refs/tags/}" + fi + + # Get the previous tag. If there is no previous tag, this will be empty. + PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -v "$RELEASE_TAG" | head -n 1) + + # Get the commit range + if [ -z "$PREVIOUS_TAG" ]; then + # If there is no previous tag, get all commits up to the current tag + COMMIT_RANGE="$RELEASE_TAG" + else + COMMIT_RANGE="$PREVIOUS_TAG..$RELEASE_TAG" + fi + + # Find the commits in this release + COMMITS=$(git log "$COMMIT_RANGE" --pretty=format:"%B") + + # Extract issues/PRs closed (simple regex, can be improved) + echo "$COMMITS" | grep -oE "#[0-9]+" | sort -u | while read ISSUE; do + ISSUE_NUMBER="${ISSUE//#/}" + COMMENT="This issue/pr has been fixed in release ${RELEASE_TAG} :tada:" + gh issue comment "$ISSUE_NUMBER" --body "$COMMENT" + done + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9cc3c2e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release Build + +on: + workflow_dispatch: + push: + branches: [ "master" ] + tags: [ "*[0-9]-release" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Extract tag name + if: startsWith(github.ref, 'refs/tags/') + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Set up environment variables + run: | + echo "GPR_USER=${{ github.actor }}" >> $GITHUB_ENV + echo "GPR_KEY=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> $GITHUB_ENV + echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV + echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV + echo "KEYSTORE_BASE64=${{ secrets.KEYSTORE_BASE64 }}" >> $GITHUB_ENV + echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - name: set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + + - name: Archive APK + uses: actions/upload-artifact@v4 + with: + name: app-release.apk + path: app/build/outputs/apk/release/app-release.apk + + - name: Create Release + id: create_release + uses: ncipollo/release-action@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + name: ${{ github.ref_name }} + prerelease: false + generateReleaseNotes: true + artifacts: app/build/outputs/apk/release/app-release.apk, app/manifest.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}