Fix windows build #16
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: Build & Release Development pre-release | |
| on: | |
| push: | |
| branches: | |
| - 'feature/dev-releases' | |
| tags: | |
| - 'v*-dev.*' | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - ubuntu-22.04-arm | |
| - windows-latest | |
| - macos-13 | |
| - macos-latest | |
| outputs: | |
| artifact-name: ${{ steps.set-artifact-name.outputs.artifact }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies and PyInstaller | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Determine version (Unix) | |
| id: get-version | |
| if: runner.os != 'Windows' | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| version="${{ github.ref }}" # Extract version from tag | |
| version="${version##*/}" | |
| else | |
| branch="${{ github.ref }}" # Extract version from branch name | |
| branch="${branch##*/}" | |
| version="dev-${branch}" | |
| fi | |
| echo "version=$version" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Determine version (Windows) | |
| id: get-version-win | |
| if: runner.os == 'Windows' | |
| run: | | |
| if ($env:GITHUB_REF -like 'refs/tags/*') { | |
| $version = $env:GITHUB_REF -replace 'refs/tags/', '' | |
| } else { | |
| $branch = $env:GITHUB_REF -replace 'refs/heads/', '' | |
| $version = "dev-$branch" | |
| } | |
| echo "version=$version" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Run build script (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| chmod +x scripts/build.sh | |
| ./scripts/build.sh | |
| - name: Run build script (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| powershell -File scripts/build.ps1 | |
| - name: Archive artifact (Unix) | |
| if: runner.os != 'Windows' | |
| id: set-artifact-name | |
| run: | | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| if [[ "$(uname -m)" == "arm64" ]]; then | |
| artifact="pgsqltoolsservice-osx-arm64-${version}.tar.gz" | |
| else | |
| artifact="pgsqltoolsservice-osx-${version}.tar.gz" | |
| fi | |
| tar -czf $artifact -C dist pgsqltoolsservice | |
| else | |
| if [[ "$(uname -m)" == "aarch64" ]]; then | |
| artifact="pgsqltoolsservice-linux-arm64-${version}.tar.gz" | |
| else | |
| artifact="pgsqltoolsservice-linux-x64-${version}.tar.gz" | |
| fi | |
| tar -czf $artifact -C dist pgsqltoolsservice | |
| fi | |
| echo "artifact=$artifact" >> $GITHUB_OUTPUT | |
| shell: bash | |
| # Archive artifact for Windows | |
| - name: Archive artifact (Windows) | |
| if: runner.os == 'Windows' | |
| id: set-artifact-name-windows | |
| shell: pwsh | |
| run: | | |
| # Build artifact name using the environment variable set previously. | |
| $artifact = "pgsqltoolsservice-win-x64-$env:version.zip" | |
| Compress-Archive -Path .\dist\pgsqltoolsservice -DestinationPath ".\$artifact" -Force | |
| Write-Output "artifact=$artifact" >> $env:GITHUB_OUTPUT | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.set-artifact-name.outputs.artifact }} | |
| path: ${{ steps.set-artifact-name.outputs.artifact }} | |
| publish: | |
| name: Publish to GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dev | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: "Development Release ${{ github.ref }}" | |
| draft: false | |
| prerelease: true | |
| - name: Upload Release Assets | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: dev | |
| asset_name: ${{ steps.set-artifact-name.outputs.artifact }} | |
| asset_content_type: application/zip | |
| - name: Set download-link output | |
| id: setlink | |
| run: | | |
| echo "download_link=https://github.com/${{ github.repository }}/releases/tag/${{ github.ref }}" >> $GITHUB_OUTPUT | |
| - name: Output download link | |
| run: | | |
| echo "Dev binaries published at: ${{ steps.setlink.outputs.download_link }}" |