feat: register TrailerService in DI container (GIT-65) #22
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
| # Auto-release when a PR with version bump is merged to main | |
| # Creates GitHub Release with changelog and publishes to npm | |
| name: Release on PR Merge | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| check-version: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version_changed: ${{ steps.version-check.outputs.changed }} | |
| new_version: ${{ steps.version-check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check if version changed | |
| id: version-check | |
| run: | | |
| # Get version from current commit | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| # Get version from previous commit | |
| git checkout HEAD~1 -- package.json 2>/dev/null || true | |
| OLD_VERSION=$(node -p "require('./package.json').version" 2>/dev/null || echo "0.0.0") | |
| # Restore current package.json | |
| git checkout HEAD -- package.json | |
| echo "Old version: $OLD_VERSION" | |
| echo "New version: $NEW_VERSION" | |
| if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then | |
| echo "Version changed from $OLD_VERSION to $NEW_VERSION" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version unchanged" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| release: | |
| needs: check-version | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history needed for changelog and tags | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| # Get commits since last tag | |
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -n "$LAST_TAG" ]; then | |
| echo "Generating changelog since $LAST_TAG" | |
| CHANGELOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges | head -50) | |
| else | |
| echo "No previous tag found, using recent commits" | |
| CHANGELOG=$(git log -20 --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| # Write to file for multi-line output | |
| echo "$CHANGELOG" > changelog.txt | |
| # Also create a summary | |
| FEAT_COUNT=$(echo "$CHANGELOG" | grep -c "^- feat" || true) | |
| FIX_COUNT=$(echo "$CHANGELOG" | grep -c "^- fix" || true) | |
| echo "features=$FEAT_COUNT" >> $GITHUB_OUTPUT | |
| echo "fixes=$FIX_COUNT" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.new_version }} | |
| name: v${{ needs.check-version.outputs.new_version }} | |
| body_path: changelog.txt | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-npm: | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history needed for GitClient tests | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Run tests | |
| run: npm test | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.npm_token }} | |
| - name: Summary | |
| run: | | |
| echo "## Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version:** v${{ needs.check-version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **npm:** https://www.npmjs.com/package/git-mem" >> $GITHUB_STEP_SUMMARY | |
| echo "- **GitHub Release:** https://github.com/${{ github.repository }}/releases/tag/v${{ needs.check-version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY |