feat: add golangci-lint linter integration with v2.x support (#51) #44
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| extract-version: | |
| name: Extract version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Extract version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./npm/package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Check if release exists | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Check if GitHub release exists | |
| if gh release view "v$VERSION" >/dev/null 2>&1; then | |
| echo "Release v$VERSION already exists, skipping release" | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "Release v$VERSION does not exist, proceeding with release" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| ci: | |
| name: Run CI | |
| needs: extract-version | |
| if: needs.extract-version.outputs.should_release == 'true' | |
| uses: ./.github/workflows/ci.yml | |
| build: | |
| name: Build | |
| needs: [extract-version, ci] | |
| if: needs.extract-version.outputs.should_release == 'true' | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| version: ${{ needs.extract-version.outputs.version }} | |
| upload-artifacts: true | |
| retention-days: 1 | |
| release: | |
| name: Create GitHub Release | |
| needs: [extract-version, ci, build] | |
| if: needs.extract-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release-assets | |
| find artifacts -type f \( -name 'sym-darwin-*' -o -name 'sym-linux-*' -o -name 'sym-windows-*' \) -exec mv {} release-assets/ \; | |
| # Verify binary count | |
| BINARY_COUNT=$(ls -1 release-assets/ | wc -l) | |
| echo "Found $BINARY_COUNT binaries" | |
| if [ "$BINARY_COUNT" -ne 5 ]; then | |
| echo "Error: Expected 5 binaries, found $BINARY_COUNT" | |
| ls -lh release-assets/ | |
| exit 1 | |
| fi | |
| echo "All 5 binaries prepared successfully" | |
| ls -lh release-assets/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.extract-version.outputs.version }} | |
| name: Release v${{ needs.extract-version.outputs.version }} | |
| files: release-assets/* | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| npm: | |
| name: Publish to npm | |
| needs: [extract-version, ci, build, release] | |
| if: needs.extract-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Copy binaries to npm package | |
| run: | | |
| mkdir -p npm/bin | |
| find artifacts -type f \( -name 'sym-*' ! -name '*.js' \) -exec cp {} npm/bin/ \; | |
| # Set executable permissions for Unix binaries | |
| chmod +x npm/bin/sym-darwin-* npm/bin/sym-linux-* 2>/dev/null || true | |
| # Verify binary count | |
| BINARY_COUNT=$(find npm/bin -name 'sym-*' -type f ! -name '*.js' | wc -l) | |
| echo "Found $BINARY_COUNT binaries in npm/bin/" | |
| if [ "$BINARY_COUNT" -ne 5 ]; then | |
| echo "Error: Expected 5 binaries, found $BINARY_COUNT" | |
| ls -lh npm/bin/ | |
| exit 1 | |
| fi | |
| echo "All 5 binaries copied to npm package successfully" | |
| ls -lh npm/bin/ | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Publish to npm | |
| working-directory: npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # deploy-coverage: | |
| # name: Deploy Coverage to GitHub Pages | |
| # needs: [extract-version, ci] | |
| # if: needs.extract-version.outputs.should_release == 'true' | |
| # runs-on: ubuntu-latest | |
| # permissions: | |
| # contents: write | |
| # steps: | |
| # - name: Download coverage artifact | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: coverage-report | |
| # path: coverage-report | |
| # - name: Deploy to GitHub Pages | |
| # uses: peaceiris/actions-gh-pages@v3 | |
| # with: | |
| # github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # publish_dir: ./coverage-report | |
| # publish_branch: gh-pages | |
| # destination_dir: coverage | |
| # keep_files: true | |
| # enable_jekyll: false | |
| # commit_message: 'Deploy coverage for v${{ needs.extract-version.outputs.version }}' | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |