Skip to content

Commit 5eae487

Browse files
authored
copied and replaced publish-binaries.yml from cargo-component (#111)
1 parent 8000e1a commit 5eae487

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: "Publish binaries"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
bump_dev_release:
11+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'bytecodealliance/wac'
12+
name: Create dev release
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Login GH CLI
18+
run: gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }})
19+
- name: Delete old dev release
20+
run: gh release delete -R bytecodealliance/wac dev -y || true
21+
- name: Create new latest release
22+
run: gh release create -R bytecodealliance/wac dev --prerelease --notes "Published artifacts from the latest build"
23+
24+
publish_dev_release:
25+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'bytecodealliance/wac'
26+
name: Publish to dev release
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix:
30+
include:
31+
- rust-target: x86_64-unknown-linux-gnu
32+
os: ubuntu-latest
33+
- rust-target: aarch64-unknown-linux-gnu
34+
os: ubuntu-latest
35+
cross: true
36+
- rust-target: x86_64-apple-darwin
37+
os: macos-latest
38+
- rust-target: aarch64-apple-darwin
39+
os: macos-latest
40+
- rust-target: x86_64-pc-windows-gnu
41+
os: windows-latest
42+
43+
needs:
44+
- bump_dev_release
45+
permissions:
46+
contents: write
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Install Rust
50+
run: rustup update stable --no-self-update && rustup default stable && rustup target add ${{ matrix.rust-target }}
51+
- run: cargo build --release --target ${{ matrix.rust-target }}
52+
if: ${{ ! matrix.cross }}
53+
- run: cargo install cross
54+
if: ${{ matrix.cross }}
55+
- run: cross build --release --target ${{ matrix.rust-target }}
56+
if: ${{ matrix.cross }}
57+
- run: mv ./target/${{ matrix.rust-target }}/release/wac.exe ./target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}
58+
if: matrix.os == 'windows-latest'
59+
- run: mv ./target/${{ matrix.rust-target }}/release/wac ./target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}
60+
if: matrix.os != 'windows-latest'
61+
- name: Login GH CLI
62+
shell: bash
63+
run: gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }})
64+
- run: gh release upload -R bytecodealliance/wac --clobber dev target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}
65+
66+
publish_tagged_release:
67+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'bytecodealliance/wac'
68+
name: Publish to tagged release
69+
runs-on: ${{ matrix.os }}
70+
strategy:
71+
matrix:
72+
include:
73+
- rust-target: x86_64-unknown-linux-gnu
74+
os: ubuntu-latest
75+
- rust-target: aarch64-unknown-linux-gnu
76+
os: ubuntu-latest
77+
cross: true
78+
- rust-target: x86_64-apple-darwin
79+
os: macos-latest
80+
- rust-target: aarch64-apple-darwin
81+
os: macos-latest
82+
- rust-target: x86_64-pc-windows-gnu
83+
os: windows-latest
84+
permissions:
85+
contents: write
86+
steps:
87+
- uses: actions/checkout@v4
88+
- name: Install Rust
89+
run: rustup update stable --no-self-update && rustup default stable && rustup target add ${{ matrix.rust-target }}
90+
- run: cargo build --release --target ${{ matrix.rust-target }}
91+
if: ${{ ! matrix.cross }}
92+
- run: cargo install cross
93+
if: ${{ matrix.cross }}
94+
- run: cross build --release --target ${{ matrix.rust-target }}
95+
if: ${{ matrix.cross }}
96+
- run: mv ./target/${{ matrix.rust-target }}/release/wac.exe ./target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}
97+
if: matrix.os == 'windows-latest'
98+
- run: mv ./target/${{ matrix.rust-target }}/release/wac ./target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}
99+
if: matrix.os != 'windows-latest'
100+
- name: Login GH CLI
101+
shell: bash
102+
run: gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }})
103+
- run: gh release upload -R bytecodealliance/wac --clobber ${{ github.ref_name }} target/${{ matrix.rust-target }}/release/wac-${{ matrix.rust-target }}

0 commit comments

Comments
 (0)