diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..e7f0521 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,133 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: write + packages: write + pull-requests: write + +env: + NODE_VERSION: 20 + APP_NAME: reddit-chat-mobile-fix + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + - name: Install Dependencies + run: npm install + - name: Build ${{ env.APP_NAME }} for Firefox + run: npm run build:firefox + + - name: Create .zip for Firefox build + uses: thedoctor0/zip-release@0.7.5 + with: + type: 'zip' + filename: 'firefox.zip' + path: 'dist/' + - name: Build ${{ env.APP_NAME }} for Chrome + run: npm run build:chrome + + - name: Create .zip for Chrome build + uses: thedoctor0/zip-release@0.7.5 + with: + type: 'zip' + filename: 'chrome.zip' + path: 'dist/' + + changelog: + name: Changelog + needs: + - lint + - build + - test + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + + outputs: + skipped: ${{ steps.changelog.outputs.skipped }} + tag: ${{ steps.changelog.outputs.tag }} + clean_changelog: ${{ steps.changelog.outputs.clean_changelog }} + version: ${{ steps.changelog.outputs.version }} + + env: + PR_BRANCH: release-ci-${{ github.sha }} + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - name: Create Branch + run: | + git checkout -b ${{ env.PR_BRANCH }} + + - name: Create Changelog + uses: TriPSs/conventional-changelog-action@dd734f74fce61a6e02f821ee1b5930bc79a23534 # v5 + id: changelog + with: + github-token: ${{ github.token }} + git-user-name: "github-actions[bot]" + git-user-email: "github-actions[bot]@users.noreply.github.com" + git-branch: ${{ env.PR_BRANCH }} + skip-git-pull: true + output-file: false + version-file: .github/package.yaml + create-summary: true + + - name: Create Changelog PR + if: steps.changelog.outputs.skipped == 'false' + run: | + gh pr create --base main --head ${{ env.PR_BRANCH }} --title 'chore(release): ${{ steps.changelog.outputs.tag }} [skip-ci]' --body '${{ steps.changelog.outputs.clean_changelog }}' + env: + GH_TOKEN: ${{ github.token }} + + - name: Approve Changelog PR + if: steps.changelog.outputs.skipped == 'false' + run: | + gh pr review --approve ${{ env.PR_BRANCH }} + env: + GH_TOKEN: ${{ secrets.GH_OWNER_TOKEN }} + + - name: Merge Changelog PR + if: steps.changelog.outputs.skipped == 'false' + run: | + gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }} + env: + GH_TOKEN: ${{ secrets.GH_OWNER_TOKEN }} + + realease: + name: realease + needs: changelog + if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false' + runs-on: ubuntu-latest + + steps: + - name: Upload Release + uses: ncipollo/release-action@v1.12.0 + with: + artifacts: "firefox.zip,chrome.zip" + token: ${{ secrets.GITHUB_TOKEN }} + generateReleaseNotes: true + draft: false + prerelease: false + tag: ${{ needs.changelog.outputs.tag }} + name: ${{ needs.changelog.outputs.tag }} + body: | +
+ 🤖 Autogenerated Conventional Changelog + + ${{ needs.changelog.outputs.clean_changelog }} +
+