|
1 | | -# inspried by https://github.com/mbhall88/lrge/blob/main/.github/workflows/release.yml |
2 | 1 | name: Release |
3 | 2 |
|
4 | 3 | on: |
5 | 4 | push: |
6 | 5 | tags: |
7 | 6 | - "[0-9]+.[0-9]+.[0-9]+" |
8 | 7 |
|
9 | | -env: |
10 | | - CICD_INTERMEDIATES_DIR: "_release-intermediates" |
11 | | - |
12 | 8 | jobs: |
13 | | - upload: |
14 | | - name: ${{ matrix.job.os }} (${{ matrix.job.target }}) |
| 9 | + release: |
| 10 | + name: Release - ${{ matrix.platform.os-name }} |
15 | 11 | permissions: |
16 | 12 | contents: write |
17 | | - runs-on: ${{ matrix.job.os }} |
| 13 | + runs-on: ${{ matrix.platform.runs-on }} |
18 | 14 | strategy: |
19 | 15 | fail-fast: false |
20 | 16 | matrix: |
21 | | - job: |
22 | | - - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, use-cross: true } |
23 | | - - { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, use-cross: true } |
24 | | - - { os: macos-14, target: x86_64-apple-darwin, use-cross: true } |
25 | | - - { os: macos-latest, target: aarch64-apple-darwin, use-cross: true } |
| 17 | + platform: |
| 18 | + - os-name: Linux-x86_64 |
| 19 | + runs-on: ubuntu-24.04 |
| 20 | + target: x86_64-unknown-linux-musl |
| 21 | + |
| 22 | + - os-name: Windows-x86_64 |
| 23 | + runs-on: windows-latest |
| 24 | + target: x86_64-pc-windows-msvc |
| 25 | + |
| 26 | + - os-name: macOS-x86_64 |
| 27 | + runs-on: macOS-latest |
| 28 | + target: x86_64-apple-darwin |
26 | 29 | steps: |
27 | | - - name: Checkout source code |
| 30 | + - name: Checkout |
28 | 31 | uses: actions/checkout@v4 |
29 | 32 |
|
30 | | - - name: Extract crate information |
31 | | - shell: bash |
32 | | - run: | |
33 | | - echo "PROJECT_NAME=hashfasta" >> $GITHUB_ENV |
34 | | - echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' lrge/Cargo.toml | head -n1)" >> $GITHUB_ENV |
35 | | - echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV |
36 | | - echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV |
37 | | -
|
38 | | - - name: Install toolchain |
39 | | - uses: dtolnay/rust-toolchain@stable |
40 | | - with: |
41 | | - targets: ${{ matrix.job.target }} |
42 | | - |
43 | | - - name: Show version information (Rust, cargo, GCC) |
44 | | - shell: bash |
45 | | - run: | |
46 | | - gcc --version || true |
47 | | - rustup -V |
48 | | - rustup toolchain list |
49 | | - rustup default |
50 | | - cargo -V |
51 | | - rustc -V |
52 | | -
|
53 | | - - name: Install cross |
54 | | - uses: taiki-e/install-action@v2 |
| 33 | + - name: Build binary |
| 34 | + uses: houseabsolute/actions-rust-cross@v1 |
55 | 35 | with: |
56 | | - tool: cross@0.2.5 |
57 | | - |
58 | | - - name: Install OpenSSL dev deps (Linux) |
59 | | - if: runner.os == 'Linux' |
60 | | - run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev |
61 | | - |
62 | | - - name: Install OpenSSL dev deps (macOS) |
63 | | - if: runner.os == 'macOS' |
64 | | - shell: bash |
65 | | - run: | |
66 | | - brew update |
67 | | - brew install pkg-config openssl@3 |
68 | | - echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> "$GITHUB_ENV" |
69 | | - echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> "$GITHUB_ENV" |
70 | | -
|
71 | | - - name: Build with cross |
72 | | - run: cross build --release --target=${{ matrix.job.target }} |
73 | | - |
74 | | - - name: Set binary name & path |
75 | | - id: bin |
76 | | - shell: bash |
77 | | - run: | |
78 | | - # Figure out suffix of binary |
79 | | - EXE_suffix="" |
80 | | - case ${{ matrix.job.target }} in |
81 | | - *-pc-windows-*) EXE_suffix=".exe" ;; |
82 | | - esac; |
83 | | -
|
84 | | - # Setup paths |
85 | | - BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}" |
86 | | - BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" |
87 | | -
|
88 | | - # Let subsequent steps know where to find the binary |
89 | | - echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT |
90 | | - echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT |
91 | | -
|
92 | | - - name: Create tarball |
93 | | - id: package |
94 | | - shell: bash |
95 | | - run: | |
96 | | - PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; |
97 | | - PKG_BASENAME=${PROJECT_NAME}-${PROJECT_VERSION}-${{ matrix.job.target }} |
98 | | - PKG_NAME=${PKG_BASENAME}${PKG_suffix} |
99 | | - echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT |
100 | | - PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" |
101 | | - ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" |
102 | | - mkdir -p "${ARCHIVE_DIR}" |
103 | | - |
104 | | - # Binary |
105 | | - cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR" |
106 | | - |
107 | | - # README, LICENSE and CHANGELOG files |
108 | | - cp "README.md" "LICENSE" "CHANGELOG.md" "$ARCHIVE_DIR" |
109 | | - |
110 | | - # base compressed package |
111 | | - pushd "${PKG_STAGING}/" >/dev/null |
112 | | - case ${{ matrix.job.target }} in |
113 | | - *-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;; |
114 | | - *) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;; |
115 | | - esac; |
116 | | - popd >/dev/null |
117 | | - |
118 | | - # Let subsequent steps know where to find the compressed package |
119 | | - echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT |
120 | | -
|
121 | | - - name: "Artifact upload: tarball" |
122 | | - uses: actions/upload-artifact@master |
123 | | - with: |
124 | | - name: ${{ steps.package.outputs.PKG_NAME }} |
125 | | - path: ${{ steps.package.outputs.PKG_PATH }} |
126 | | - |
127 | | - - name: Check for release |
128 | | - id: is-release |
129 | | - shell: bash |
130 | | - run: | |
131 | | - unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then IS_RELEASE='true' ; fi |
132 | | - echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT |
| 36 | + command: build |
| 37 | + target: ${{ matrix.platform.target }} |
| 38 | + args: "--locked --release" |
| 39 | + strip: true |
133 | 40 |
|
134 | | - - name: Publish archives and packages |
135 | | - uses: softprops/action-gh-release@v2 |
136 | | - if: steps.is-release.outputs.IS_RELEASE |
| 41 | + - name: Publish artifacts and release |
| 42 | + uses: houseabsolute/actions-rust-release@v0 |
137 | 43 | with: |
138 | | - files: | |
139 | | - ${{ steps.package.outputs.PKG_PATH }} |
140 | | - env: |
141 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + executable-name: hashfasta |
| 45 | + target: ${{ matrix.platform.target }} |
0 commit comments