Build binaries and create release #102
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: Build binaries and create release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: 'Select the type of release to create' | |
| type: choice | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| push: | |
| branches: | |
| - 'master' | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| if: github.ref_type != 'tag' || inputs.release_type != null | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| artifact: gql-federation-schema-parser-linux | |
| - os: macos-latest | |
| platform: macos | |
| artifact: gql-federation-schema-parser-macos | |
| - os: windows-latest | |
| platform: windows | |
| artifact: gql-federation-schema-parser-win.exe | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.4.1 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build binary | |
| run: bun build ./src/index.ts --compile --outfile=./dist/${{ matrix.artifact }} | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: ./dist/${{ matrix.artifact }} | |
| if-no-files-found: error | |
| changelog: | |
| name: Generate Changelog | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref_type != 'tag' && inputs.release_type != null | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ github.token }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Generate changelog | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "tiagoboeing@users.noreply.github.com" | |
| npx changelogen@latest --release --bump --push --${{inputs.release_type}} --token ${{ github.token }} | |
| - name: Dispatch gh release workflow | |
| run: | | |
| new_tag=$(git describe --tags --abbrev=0) | |
| echo "Created new tag: $new_tag" | |
| gh workflow run release.yml --ref $new_tag | |
| env: | |
| GH_TOKEN: ${{ github.token }} |