index : rust-template
Feature rich rust template
about summary refs log tree commit diff
rust-template / .github / workflows / release.yml
-rw-r--r-- blob 3c01cfd13b14b27317a0ca70699f1c53c84d3e92 2190 bytes (plain)
1
name: Release
2
3
on:
4
  push:
5
    tags:
6
      - "v*"
7
8
permissions:
9
  contents: write
10
11
jobs:
12
  build:
13
    name: Build {% raw %}${{ matrix.target }}{% endraw %}
14
    runs-on: {% raw %}${{ matrix.os }}{% endraw %}
15
    strategy:
16
      matrix:
17
        include:
18
          - target: x86_64-unknown-linux-gnu
19
            os: ubuntu-latest
20
            binary: {{project-name}}
21
            asset: {{project-name}}-x86_64-linux
22
          - target: aarch64-unknown-linux-gnu
23
            os: ubuntu-latest
24
            binary: {{project-name}}
25
            asset: {{project-name}}-aarch64-linux
26
    steps:
27
      - uses: actions/checkout@v4
28
29
      - name: Install Rust
30
        uses: dtolnay/rust-toolchain@stable
31
        with:
32
          targets: {% raw %}${{ matrix.target }}{% endraw %}
33
34
      - uses: Swatinem/rust-cache@v2
35
36
      - name: Install cross
37
        run: cargo install cross --locked
38
39
      - name: Build release binary
40
        run: cross build --release --target {% raw %}${{ matrix.target }}{% endraw %}
41
42
      - name: Rename binary
43
        run: cp target/{% raw %}${{ matrix.target }}/release/${{ matrix.binary }} ${{ matrix.asset }}{% endraw %}
44
45
      - name: Upload artifact
46
        uses: actions/upload-artifact@v4
47
        with:
48
          name: {% raw %}${{ matrix.asset }}{% endraw %}
49
          path: {% raw %}${{ matrix.asset }}{% endraw %}
50
51
  release:
52
    name: Create GitHub Release
53
    needs: build
54
    runs-on: ubuntu-latest
55
    steps:
56
      - uses: actions/checkout@v4
57
58
      - name: Download all artifacts
59
        uses: actions/download-artifact@v4
60
        with:
61
          path: artifacts
62
          merge-multiple: true
63
64
      - name: Extract changelog notes for tag
65
        id: changelog
66
        run: |
67
          {% raw %}VERSION=${GITHUB_REF#refs/tags/v}
68
          NOTES=$(awk "/## \[$VERSION\]/{flag=1; next} /## \[/{flag=0} flag" CHANGELOG.md)
69
          {
70
            echo "notes<<EOF"
71
            echo "$NOTES"
72
            echo "EOF"
73
          } >> "$GITHUB_OUTPUT"{% endraw %}
74
75
      - name: Publish GitHub Release
76
        uses: softprops/action-gh-release@v2
77
        with:
78
          body: {% raw %}${{ steps.changelog.outputs.notes }}{% endraw %}
79
          files: artifacts/*