Fixed release.yml file V2 #7
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| upload_url: ${{ steps.release.outputs.upload_url }} | |
| release_id: ${{ steps.release.outputs.id }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create Release | |
| id: release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') || contains(github.ref_name, 'unstable') }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-release: | |
| needs: create-release | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| name: netmgr-linux-x86_64 | |
| - os: ubuntu-22.04 | |
| target: aarch64-unknown-linux-gnu | |
| name: netmgr-linux-aarch64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| name: netmgr-macos-x86_64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| name: netmgr-macos-aarch64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| name: netmgr-windows-x86_64.exe | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools (Linux) | |
| if: matrix.os == 'ubuntu-22.04' && matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Install cargo-deb (Linux only) | |
| if: matrix.os == 'ubuntu-22.04' | |
| run: cargo install cargo-deb | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build release binary | |
| run: | | |
| if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then | |
| export CC=aarch64-linux-gnu-gcc | |
| export CXX=aarch64-linux-gnu-g++ | |
| export AR=aarch64-linux-gnu-ar | |
| export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
| fi | |
| cargo build --release --target ${{ matrix.target }} | |
| shell: bash | |
| - name: Strip binary (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then | |
| aarch64-linux-gnu-strip target/${{ matrix.target }}/release/netmgr | |
| else | |
| strip target/${{ matrix.target }}/release/netmgr | |
| fi | |
| - name: Prepare binary (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cp target/${{ matrix.target }}/release/netmgr ${{ matrix.name }} | |
| chmod +x ${{ matrix.name }} | |
| - name: Prepare binary (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cp target/${{ matrix.target }}/release/netmgr.exe ${{ matrix.name }} | |
| - name: Build Debian package (Linux x86_64 only) | |
| if: matrix.os == 'ubuntu-22.04' && matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: | | |
| cargo deb --target ${{ matrix.target }} | |
| cp target/${{ matrix.target }}/debian/*.deb netmgr_${{ github.ref_name }}_amd64.deb | |
| - name: Upload Release Assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| files: | | |
| ${{ matrix.name }} | |
| ${{ matrix.os == 'ubuntu-22.04' && matrix.target == 'x86_64-unknown-linux-gnu' && format('netmgr_{0}_amd64.deb', github.ref_name) || '' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |