Created
December 30, 2023 09:53
-
-
Save alexng353/7953dd5184ec1b65783289a5a31780fa to your computer and use it in GitHub Desktop.
Revisions
-
alexng353 created this gist
Dec 30, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,148 @@ # modified from https://github.com/railwayapp/cli/blob/master/.github/workflows/release.yml # just replce every instance of "ENVX" or "envx" with your app name (or leave it, I don't care) name: CD on: push: branches: - main jobs: release-please: runs-on: ubuntu-latest permissions: contents: write pull-requests: write outputs: envx_version: ${{ env.ENVX_VERSION }} build: ${{ env.BUILD }} steps: - name: Release Please uses: GoogleCloudPlatform/release-please-action@v3 id: release with: token: ${{ secrets.GITHUB_TOKEN }} release-type: rust - name: Set SemVer String id: set-semver if: steps.release.outputs.release_created == 'true' run: | echo "ENVX_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}" >> $GITHUB_ENV echo "BUILD=true" >> $GITHUB_ENV build-release: name: Build Release needs: [release-please] if: needs.release-please.outputs.build == 'true' runs-on: ${{ matrix.os }} continue-on-error: true strategy: matrix: include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest - target: x86_64-unknown-linux-musl os: ubuntu-latest # - target: i686-unknown-linux-musl # os: ubuntu-latest - target: aarch64-unknown-linux-musl os: ubuntu-latest - target: arm-unknown-linux-musleabihf os: ubuntu-latest - target: x86_64-apple-darwin os: macOS-latest - target: aarch64-apple-darwin os: macOS-latest - target: x86_64-pc-windows-msvc os: windows-latest # - target: i686-pc-windows-msvc # os: windows-latest - target: x86_64-pc-windows-gnu os: windows-latest # - target: i686-pc-windows-gnu # os: windows-latest # use-cross: true steps: - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 1 - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} profile: minimal override: true # openssl is OPTIONAL - name: Install openssl if: matrix.os == 'ubuntu-latest' run: sudo apt-get install libssl-dev pkg-config -y - name: Build release binary uses: actions-rs/cargo@v1 with: command: build args: --release --locked --target ${{ matrix.target }} use-cross: ${{ matrix.use-cross || matrix.os == 'ubuntu-latest' }} - name: Prepare binaries (zip) [Windows] if: matrix.os == 'windows-latest' run: | cd target/${{ matrix.target }}/release strip envx.exe 7z a ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.zip envx.exe cd - - name: Prepare binaries (tar) [Windows] if: matrix.os == 'windows-latest' run: | cd target/${{ matrix.target }}/release strip envx.exe 7z a -ttar archive.tar envx.exe 7z a -tgzip ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz archive.tar cd - - name: Prepare binaries [-linux] if: matrix.os != 'windows-latest' run: | cd target/${{ matrix.target }}/release strip envx || true tar czvf ../../../envx-${{ needs.release-please.outputs.envx_version }}-${{ matrix.target }}.tar.gz envx cd - - name: Upload release archive uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: v${{ needs.create-release.outputs.envx_version }} files: envx-${{ needs.create-release.outputs.envx_version }}-${{ matrix.target }}* - name: Install cargo-deb if: matrix.target == 'x86_64-unknown-linux-musl' run: cargo install cargo-deb - name: Generate .deb package file if: matrix.target == 'x86_64-unknown-linux-musl' run: cargo deb --target x86_64-unknown-linux-musl --output envx-${{ needs.create-release.outputs.envx_version }}-amd64.deb - name: Upload .deb package file if: matrix.target == 'x86_64-unknown-linux-musl' uses: svenstaro/upload-release-action@v2 with: tag: ${{ needs.create-release.outputs.envx_version }} file: envx-${{ needs.create-release.outputs.envx_version }}-amd64.deb