|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build FlutterGuard CLI |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 15 | + include: |
| 16 | + - os: ubuntu-latest |
| 17 | + goos: linux |
| 18 | + goarch: amd64 |
| 19 | + filename: flutterguard-cli |
| 20 | + artifact_name: flutterguard-cli-linux-amd64 |
| 21 | + - os: ubuntu-latest |
| 22 | + goos: linux |
| 23 | + goarch: arm64 |
| 24 | + filename: flutterguard-cli |
| 25 | + artifact_name: flutterguard-cli-linux-arm64 |
| 26 | + - os: macos-latest |
| 27 | + goos: darwin |
| 28 | + goarch: amd64 |
| 29 | + filename: flutterguard-cli |
| 30 | + artifact_name: flutterguard-cli-darwin-amd64 |
| 31 | + - os: macos-latest |
| 32 | + goos: darwin |
| 33 | + goarch: arm64 |
| 34 | + filename: flutterguard-cli |
| 35 | + artifact_name: flutterguard-cli-darwin-arm64 |
| 36 | + - os: windows-latest |
| 37 | + goos: windows |
| 38 | + goarch: amd64 |
| 39 | + filename: flutterguard-cli.exe |
| 40 | + artifact_name: flutterguard-cli-windows-amd64.exe |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Set up Go |
| 47 | + uses: actions/setup-go@v4 |
| 48 | + with: |
| 49 | + go-version: '1.21' |
| 50 | + |
| 51 | + - name: Build on Linux/macOS |
| 52 | + if: matrix.os != 'windows-latest' |
| 53 | + run: | |
| 54 | + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/${{ matrix.artifact_name }} |
| 55 | + env: |
| 56 | + CGO_ENABLED: 0 |
| 57 | + |
| 58 | + - name: Build on Windows |
| 59 | + if: matrix.os == 'windows-latest' |
| 60 | + run: | |
| 61 | + go build -o build/${{ matrix.artifact_name }} |
| 62 | + env: |
| 63 | + GOOS: ${{ matrix.goos }} |
| 64 | + GOARCH: ${{ matrix.goarch }} |
| 65 | + CGO_ENABLED: 0 |
| 66 | + |
| 67 | + - name: Upload artifact |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: ${{ matrix.artifact_name }} |
| 71 | + path: build/${{ matrix.artifact_name }} |
| 72 | + |
| 73 | + release: |
| 74 | + name: Create Release |
| 75 | + needs: build |
| 76 | + runs-on: ubuntu-latest |
| 77 | + permissions: |
| 78 | + contents: write |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Download all artifacts |
| 85 | + uses: actions/download-artifact@v3 |
| 86 | + with: |
| 87 | + path: build |
| 88 | + |
| 89 | + - name: List artifacts |
| 90 | + run: ls -la build/ |
| 91 | + |
| 92 | + - name: Create Release |
| 93 | + uses: softprops/action-gh-release@v1 |
| 94 | + with: |
| 95 | + files: | |
| 96 | + build/flutterguard-cli-linux-amd64/flutterguard-cli-linux-amd64 |
| 97 | + build/flutterguard-cli-linux-arm64/flutterguard-cli-linux-arm64 |
| 98 | + build/flutterguard-cli-darwin-amd64/flutterguard-cli-darwin-amd64 |
| 99 | + build/flutterguard-cli-darwin-arm64/flutterguard-cli-darwin-arm64 |
| 100 | + build/flutterguard-cli-windows-amd64.exe/flutterguard-cli-windows-amd64.exe |
| 101 | + draft: false |
| 102 | + prerelease: false |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments