CI: Create darwin universal binary and arm64 binary #42
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" | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-24.04, ubuntu-24.04-arm, macos-13, macos-14] # linux-x86_64, linux-arm64, darwin-x86_64, darwin-arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23.11' | |
| - run: make test | |
| - run: make package | |
| - run: shasum -a 256 node_exporter node_exporter*.tar.gz | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: package-${{ matrix.os }} | |
| path: "*.tar.gz" | |
| create-universal-binary: | |
| runs-on: macos-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download macOS x86_64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: package-macos-13 | |
| path: ./macos-x86_64 | |
| - name: Download macOS arm64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: package-macos-14 | |
| path: ./macos-arm64 | |
| - name: Extract binaries | |
| run: | | |
| cd macos-x86_64 && tar -xzf *.tar.gz | |
| cd ../macos-arm64 && tar -xzf *.tar.gz | |
| - name: Create universal binary | |
| run: | | |
| lipo -create -output node_exporter_universal \ | |
| macos-x86_64/node_exporter \ | |
| macos-arm64/node_exporter | |
| - name: Verify universal binary | |
| run: | | |
| file node_exporter_universal | |
| lipo -info node_exporter_universal | |
| - name: Package universal binary | |
| run: | | |
| mv node_exporter_universal node_exporter | |
| PACKAGE_NAME=node_exporter-stable-darwin-universal.tar.gz | |
| tar -czvf ${PACKAGE_NAME} node_exporter | |
| - name: Generate checksum | |
| run: shasum -a 256 node_exporter node_exporter*.tar.gz | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: package-darwin-universal | |
| path: "*.tar.gz" |