Add support for multiple platforms in Docker release #11
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 and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build and Package Release | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-15-intel | |
| GOOS: darwin | |
| GOARCH: amd64 | |
| target: darwin-amd64 | |
| ext: "" | |
| - os: macos-latest | |
| GOOS: darwin | |
| GOARCH: arm64 | |
| target: darwin-arm64 | |
| ext: "" | |
| - os: ubuntu-latest | |
| GOOS: linux | |
| GOARCH: amd64 | |
| target: linux-amd64 | |
| ext: "" | |
| - os: windows-latest | |
| GOOS: windows | |
| GOARCH: amd64 | |
| target: windows-amd64 | |
| ext: ".exe" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install UI dependencies | |
| working-directory: web | |
| run: npm install | |
| - name: Build UI assets | |
| working-directory: web | |
| run: npm run build | |
| - name: Install GUI dependencies (Linux) | |
| if: matrix.GOOS == 'linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev pkg-config | |
| sudo ln -sf /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.1.pc /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.25.3' | |
| - name: Get tag name | |
| shell: bash | |
| run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| - name: Build binary | |
| shell: bash | |
| env: | |
| EXTRA_GUI_LDFLAGS: ${{ matrix.GOOS == 'windows' && '-H=windowsgui' || '' }} | |
| run: | | |
| mkdir -p dist | |
| GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }} go build -ldflags="${LDFLAGS}" -o "dist/xcstrings-translator-${{ matrix.target }}${{ matrix.ext }}" . | |
| CGO_ENABLED=1 GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }} go build -tags gui -ldflags="${LDFLAGS} ${EXTRA_GUI_LDFLAGS}" -o "dist/xcstrings-translator-${{ matrix.target }}-gui${{ matrix.ext }}" . | |
| chmod +x dist/* | |
| - name: Package as ZIP (non-Windows) | |
| if: matrix.GOOS != 'windows' | |
| shell: bash | |
| run: | | |
| cd dist | |
| zip "xcstrings-translator-${{ matrix.target }}.zip" "xcstrings-translator-${{ matrix.target }}${{ matrix.ext }}" "xcstrings-translator-${{ matrix.target }}-gui${{ matrix.ext }}" | |
| - name: Package as ZIP (Windows) | |
| if: matrix.GOOS == 'windows' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path "dist/xcstrings-translator-${{ matrix.target }}${{ matrix.ext }}","dist/xcstrings-translator-${{ matrix.target }}-gui${{ matrix.ext }}" -DestinationPath "dist/xcstrings-translator-${{ matrix.target }}.zip" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: xcstrings-translator-${{ matrix.target }} | |
| path: dist/xcstrings-translator-${{ matrix.target }}.zip | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: assets | |
| - name: Display structure of downloaded files | |
| run: ls -R assets | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| assets/*/*.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |