|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Configure your build and release platforms |
| 4 | +env: |
| 5 | + # If your repo name differs from your binary name, change it. |
| 6 | + # Check you Cargo.toml -> package -> name |
| 7 | + binary: ${{ github.event.repository.name }} |
| 8 | + |
| 9 | + # Build platforms |
| 10 | + |
| 11 | + # Valid platforms: "linux, windows, macos_intel, macos_apple_silicon" |
| 12 | + # - Write "intel" and "apple" to abbreviate "macos_intel" and "macos_apple_silicon," respectively. |
| 13 | + # - Write "macos" to build for both "intel" and "apple" |
| 14 | + build_for: "linux,windows,macos" |
| 15 | + |
| 16 | + # Releases |
| 17 | + |
| 18 | + # Valid platforms: "github_releases" |
| 19 | + # - For brevity you can write: "releases" |
| 20 | + publish_to: "github_releases" |
| 21 | + |
| 22 | +permissions: |
| 23 | + # To upload files to GitHub Releases |
| 24 | + contents: write |
| 25 | + # To verify the deployment originates from an appropriate source |
| 26 | + id-token: write |
| 27 | + |
| 28 | +on: |
| 29 | + push: |
| 30 | + tags: |
| 31 | + - "*" |
| 32 | + workflow_dispatch: |
| 33 | + inputs: |
| 34 | + tag: |
| 35 | + description: "Add tag version: (e.g. -> v3.6.1)" |
| 36 | + required: true |
| 37 | + type: string |
| 38 | + build_for: |
| 39 | + description: "Build for:" |
| 40 | + default: linux,windows,macos |
| 41 | + publish_to: |
| 42 | + description: "Publish to:" |
| 43 | + default: github_releases |
| 44 | + |
| 45 | +jobs: |
| 46 | + # Load variables |
| 47 | + load-env: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + outputs: |
| 52 | + run_build_linux: ${{ (inputs.tag && contains(inputs.build_for, 'linux')) || (!inputs.tag && contains(env.build_for, 'linux') ) }} |
| 53 | + run_build_windows: ${{ ( inputs.tag && contains(inputs.build_for, 'windows')) || (!inputs.tag && contains(env.build_for, 'windows') ) }} |
| 54 | + run_build_macos_intel: ${{ ( inputs.tag && ( contains(inputs.build_for, 'intel') || contains(inputs.build_for, 'macos') )) || (!inputs.tag && (contains(env.build_for, 'intel') || contains(env.build_for, 'macos')) ) }} |
| 55 | + run_build_macos_apple_silicon: ${{ ( inputs.tag && ( contains(inputs.build_for, 'apple') || contains(inputs.build_for, 'macos') )) || (!inputs.tag && (contains(env.build_for, 'apple') || contains(env.build_for, 'macos')) ) }} |
| 56 | + run_publish_github_releases: ${{ ( inputs.tag && contains(inputs.publish_to, 'releases')) || (!inputs.tag && contains(env.publish_to, 'releases') ) }} |
| 57 | + tag: ${{ ( inputs.tag || github.ref_name ) }} |
| 58 | + binary: ${{ env.binary }} |
| 59 | + |
| 60 | + # Build for Linux x86_64 |
| 61 | + build-linux: |
| 62 | + needs: load-env |
| 63 | + if: needs.load-env.outputs.run_build_linux == 'true' |
| 64 | + uses: ./.github/workflows/linux.yaml |
| 65 | + name: build |
| 66 | + with: |
| 67 | + tag: ${{ needs.load-env.outputs.tag }} |
| 68 | + binary: ${{ needs.load-env.outputs.binary }} |
| 69 | + |
| 70 | + # Build for Windows x86_64 |
| 71 | + build-windows: |
| 72 | + needs: load-env |
| 73 | + if: needs.load-env.outputs.run_build_windows == 'true' |
| 74 | + uses: ./.github/workflows/windows.yaml |
| 75 | + name: build |
| 76 | + with: |
| 77 | + tag: ${{ needs.load-env.outputs.tag }} |
| 78 | + binary: ${{ needs.load-env.outputs.binary }} |
| 79 | + |
| 80 | + |
| 81 | + # Build for MacOS x86_64/ARM64 |
| 82 | + build-macos: |
| 83 | + needs: load-env |
| 84 | + if: needs.load-env.outputs.run_build_macos_intel == 'true' || needs.load-env.outputs.run_build_macos_apple_silicon == 'true' |
| 85 | + uses: ./.github/workflows/macos.yaml |
| 86 | + name: build |
| 87 | + with: |
| 88 | + tag: ${{ needs.load-env.outputs.tag }} |
| 89 | + binary: ${{ needs.load-env.outputs.binary }} |
| 90 | + run_macos_intel: ${{ needs.load-env.outputs.run_build_macos_intel }} |
| 91 | + run_macos_apple_silicon: ${{ needs.load-env.outputs.run_build_macos_apple_silicon }} |
| 92 | + |
| 93 | + |
| 94 | + # Release binaries in GitHub |
| 95 | + publish-github-releases: |
| 96 | + needs: |
| 97 | + - load-env |
| 98 | + - build-linux |
| 99 | + - build-windows |
| 100 | + - build-macos |
| 101 | + if: ${{ always() && !failure() && !cancelled() && needs.load-env.outputs.run_publish_github_releases == 'true'}} |
| 102 | + strategy: |
| 103 | + fail-fast: false |
| 104 | + matrix: |
| 105 | + include: |
| 106 | + - artifact_name: linux-x86_64 |
| 107 | + os: ubuntu-latest |
| 108 | + - artifact_name: windows-x86_64 |
| 109 | + os: windows-latest |
| 110 | + - artifact_name: darwin-x86_64 |
| 111 | + os: macos-latest |
| 112 | + - artifact_name: darwin-aarch64 |
| 113 | + os: macos-latest |
| 114 | + uses: ./.github/workflows/github_releases.yaml |
| 115 | + name: publish / github-releases |
| 116 | + with: |
| 117 | + tag: ${{ needs.load-env.outputs.tag }} |
| 118 | + os: ${{ matrix.os }} |
| 119 | + artifact_name: ${{ matrix.artifact_name }} |
| 120 | + secrets: inherit |
0 commit comments