-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (112 loc) · 3.57 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Release
on:
workflow_dispatch:
inputs:
version:
type: choice
required: true
description: 'Version number to bump'
options:
- patch
- minor
- major
permissions:
contents: write
issues: write
pull-requests: write
jobs:
tag-bump:
name: Tag Bump
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set-tag.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-edit
- id: cargo-set-version
name: Set Version
run: cargo set-version --bump ${{ inputs.version }}
- name: Set Tag as Output
id: set-tag
run: |
CARGO_TOML_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' Cargo.toml)
echo "::set-output name=tag::$CARGO_TOML_VERSION"
- name: Print Tag
run: echo ${{ steps.set-tag.outputs.tag }}
- name: Create Commit
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "chore: bump version to v${{ steps.set-tag.outputs.tag }}"
git push origin main --follow-tags
release:
name: Create Release
needs: tag-bump
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/github-script@v5
with:
script: |
await github.request(`POST /repos/${{ github.repository }}/releases`, {
tag_name: "v${{ needs.tag-bump.outputs.tag }}",
generate_release_notes: true
});
artifacts:
needs:
- tag-bump
- release
name: Upload Artifacts ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
name:
- linux-x64-musl
include:
- name: linux-x64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
exe: rustacean-authorship-action
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: "refs/tags/v${{ needs.tag-bump.outputs.tag }}"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install ${{ matrix.name }} System Dependencies
if: matrix.name == 'linux-x64-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build for Release
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare Binary
shell: bash
run: |
chmod +x ./target/${{ matrix.target }}/release/${{ matrix.exe }}
cp ./target/${{ matrix.target }}/release/${{ matrix.exe }} ./rustacean-authorship-action-${{ matrix.os }}
- name: Attach Binary
uses: svenstaro/upload-release-action@2.9.0
with:
asset_name: rustacean-authorship-action-${{ matrix.os }}
file: rustacean-authorship-action-${{ matrix.os }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: "v${{ needs.tag-bump.outputs.tag }}"