1
0
hugo/content/blog/2022-02-10-github.md

79 lines
2.4 KiB
Markdown
Raw Normal View History

2024-04-23 13:21:26 +00:00
+++
date = "2022-02-10"
tags = ["github","rust"]
title = "github actionsでrustのcross compile"
slug = "github"
+++
opensslのerrorが出る場合は`sudo apt-get install -y -qq pkg-config libssl-dev`するといいらしい。
windowsのbuildやuploadは、同じ内容でも、うまく行ったり行かなかったりしたので、そのうち動かなくなりそう。
```yml:.github/workflows/releases.yml
name: release
on:
push:
tags:
- '*'
jobs:
build:
name: release binary
strategy:
matrix:
include:
- os: macos-latest
artifact_prefix: macos
target: x86_64-apple-darwin
artifact_name: msr
asset_name: msr-x86_64-apple-darwin
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu
artifact_name: msr
asset_name: msr-x86_64-unknown-linux-gnu
- os: windows-latest
artifact_prefix: windows
target: x86_64-pc-windows-msvc
artifact_name: msr.exe
asset_name: msr-x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: installing rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: installing needed macos dependencies
if: matrix.os == 'macos-latest'
run: brew install openssl@1.1
- name: installing needed ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
sudo apt-get install -y -qq mingw-w64
- name: running cargo build
uses: actions-rs/cargo@v1
with:
command: build
toolchain: ${{ matrix.rust }}
args: --release --target ${{ matrix.target }}
- name: upload binaries to release
uses: svenstaro/upload-release-action@2.1.1
with:
repo_token: ${{ secrets.github_token }}
file: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
overwrite: true
```