Backend Release PR #13
  
    
      This file contains hidden or 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: Backend Release PR | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| type: | |
| type: choice | |
| description: Choose release type | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| beta: | |
| type: boolean | |
| description: Prerelease | |
| default: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| releaseIt: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: services/backend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Use the app token for checkout as well | |
| token: ${{ secrets.APP_INSTALLATION_TOKEN }} | |
| - name: git config | |
| run: | | |
| git config user.name "${GITHUB_ACTOR}" | |
| git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - run: npm ci | |
| - name: Prepare release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }} | |
| TYPE_ARG: ${{ fromJSON('{"patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }} | |
| BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }} | |
| run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG | |
| - name: get-npm-version | |
| id: package-version | |
| uses: martinbeentjes/npm-get-version-action@main | |
| with: | |
| path: services/backend | |
| - name: Extract release notes | |
| id: extract-release-notes | |
| run: | | |
| # Get the current version from the package.json in the current working directory | |
| VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4) | |
| echo "Extracting release notes for version $VERSION" | |
| # Extract the changelog section for this version | |
| if [ -f CHANGELOG.md ]; then | |
| # Look for the version header and extract content until the next version or end of file | |
| RELEASE_NOTES=$(awk -v version="$VERSION" ' | |
| BEGIN { found=0; content="" } | |
| /^##? [0-9]+\.[0-9]+\.[0-9]+/ { | |
| if (found) exit | |
| if ($0 ~ version) { found=1; next } | |
| } | |
| found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit } | |
| found { content = content $0 "\n" } | |
| END { print content } | |
| ' CHANGELOG.md) | |
| # Clean up empty markdown links and remove empty lines | |
| CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed 's/(\[\]([^)]*))//g' | sed '/^$/d') | |
| # Save to output | |
| echo "release_notes<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "Release notes extracted:" | |
| echo "$CLEAN_NOTES" | |
| else | |
| echo "No CHANGELOG.md found" | |
| echo "release_notes=" >> $GITHUB_OUTPUT | |
| fi | |
| working-directory: services/backend | |
| - name: Create pull request | |
| uses: peter-evans/create-pull-request@v7 | |
| id: cpr | |
| with: | |
| # This is the key change - use the app token | |
| token: ${{ secrets.APP_INSTALLATION_TOKEN }} | |
| branch: backend-release | |
| delete-branch: true | |
| commit-message: 'chore(backend): release v${{ steps.package-version.outputs.current-version}}' | |
| title: '[Backend Release] v${{ steps.package-version.outputs.current-version}}' | |
| body: | | |
| ## Backend Release v${{ steps.package-version.outputs.current-version}} | |
| This PR prepares a new backend release. | |
| When merged, this will: | |
| 1. Create a release tag | |
| 2. Build and publish a multi-architecture Docker image to Docker Hub | |
| The Docker image will be available at: | |
| - `deploystack/backend:latest` | |
| - `deploystack/backend:v${{ steps.package-version.outputs.current-version}}` | |
| ### Supported Architectures | |
| - `linux/amd64` (Intel/AMD) | |
| - `linux/arm64` (Apple Silicon, AWS Graviton) | |
| ### Environment Variables | |
| The Docker image will include `DEPLOYSTACK_BACKEND_VERSION` environment variable set to the current version. | |
| ## Release notes: | |
| ${{ steps.extract-release-notes.outputs.release_notes }} | |
| labels: | | |
| backend | |
| release | |
| automated pr | |
| draft: false | |
| - name: Show PR link | |
| if: ${{ steps.cpr.outputs.pull-request-url }} | |
| run: | | |
| echo "Backend Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}" |