feat: support linux compilation #2
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: Go | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build_on_macos: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go get golang.org/x/tools/cmd/goimports@latest | |
| go get github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Lint | |
| run: | | |
| make lint || true | |
| - name: Build | |
| run: | | |
| GOARCH=arm64 go build -ldflags="-s -w" -o mobilectl-arm64 | |
| GOARCH=amd64 go build -ldflags="-s -w" -o mobilectl-amd64 | |
| lipo mobilectl-arm64 mobilectl-amd64 -create -output mobilectl-darwin | |
| rm mobilectl-arm64 mobilectl-amd64 | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: | | |
| mobilectl-darwin | |
| retention-days: 1 | |
| overwrite: true | |
| build_on_linux: | |
| runs-on: ubuntu-latest | |
| needs: build_on_macos | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go get golang.org/x/tools/cmd/goimports@latest | |
| go get github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Build | |
| run: | | |
| GOARCH=arm64 go build -ldflags="-s -w" -o mobilectl-linux-arm64 | |
| GOARCH=amd64 go build -ldflags="-s -w" -o mobilectl-linux-amd64 | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: | | |
| mobilectl-darwin | |
| mobilectl-linux-arm64 | |
| mobilectl-linux-amd64 | |
| retention-days: 1 | |
| overwrite: true | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: build_on_linux | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download darwin build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: mobilectl-darwin | |
| - name: Download linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: mobilectl-linux | |
| - uses: AButler/upload-release-assets@v2.0 | |
| with: | |
| files: "*.zip" | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| release-tag: ${{ env.release_tag }} | |
| - name: Publish NPM | |
| env: | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| run: | | |
| # prepare binaries for distribution | |
| find . -ls | |
| mv ./mobilectl-darwin/mobilectl-darwin publish/npm/bin/mobilectl-darwin | |
| chmod +x publish/npm/bin/* | |
| # setup npmrc | |
| echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/.npmrc | |
| # sed -i 's/\"local-build\"/\"${{ env.release_tag }}\"/' package.json | |
| # publish to npm | |
| cd publish/npm | |
| npm install | |
| #npm publish |