[Gateway Release] v0.6.0 #15
Workflow file for this run
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: Gateway Release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| paths: | |
| - 'services/gateway/**' | |
| permissions: | |
| contents: write | |
| packages: write | |
| issues: write | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'gateway') && contains(github.event.pull_request.labels.*.name, 'release') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| 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 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: | | |
| npm ci || { | |
| echo "npm ci failed, trying clean install..." | |
| npm install --no-optional | |
| } | |
| - name: Gateway Build | |
| working-directory: services/gateway | |
| run: npm run build | |
| - name: Gateway Unit Tests | |
| working-directory: services/gateway | |
| run: npm run test:unit || echo "Tests not implemented yet, skipping" | |
| - name: Gateway Lint | |
| working-directory: services/gateway | |
| run: npm run lint | |
| - name: Create Release | |
| working-directory: services/gateway | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Let release-it handle the release process properly | |
| npm run release -- --ci --verbose --no-git.requireCleanWorkingDir | |
| - name: Publish to NPM | |
| working-directory: services/gateway | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| # Publish the built package to NPM | |
| npm publish --access public | |
| - name: Get version | |
| id: package-version | |
| uses: martinbeentjes/npm-get-version-action@main | |
| with: | |
| path: services/gateway | |
| - name: Extract release notes | |
| id: extract-release-notes | |
| run: | | |
| VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4) | |
| echo "Extracting release notes for version $VERSION" | |
| if [ -f CHANGELOG.md ]; then | |
| 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_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d') | |
| 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/gateway | |
| - name: Update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: gateway-v${{ steps.package-version.outputs.current-version }} | |
| name: Gateway v${{ steps.package-version.outputs.current-version }} | |
| body: | | |
| ## Gateway Release v${{ steps.package-version.outputs.current-version }} | |
| The npm package is available at: | |
| - `@deploystack/gateway@latest` | |
| - `@deploystack/gateway@v${{ steps.package-version.outputs.current-version }}` | |
| ### Installation | |
| ```bash | |
| npm install -g @deploystack/gateway@${{ steps.package-version.outputs.current-version }} | |
| ``` | |
| ## Release notes: | |
| ${{ steps.extract-release-notes.outputs.release_notes }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }} |