-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (104 loc) · 3.55 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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
deployments: write
jobs:
draft_release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release-drafter.outputs.tag_name }}
version_name: ${{ env.VERSION }}
steps:
# Get next version
- uses: release-drafter/release-drafter@v6
id: release-drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create version string from tag (v1.0.0 -> 1.0.0)
- name: Create version string
run: |
export TAG_NAME=${{ steps.release-drafter.outputs.tag_name }}
echo "VERSION=${TAG_NAME:1}" >> $GITHUB_ENV
publish_release:
name: Release
environment:
name: prod
url: https://crates.io/crates/junit2json
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
needs: [draft_release]
steps:
# Use GitHub App for bypass ruleset guard when git push by cargo release
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.BYPASS_APP_ID }}
private-key: ${{ secrets.BYPASS_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
token: ${{ steps.app-token.outputs.token }}
- name: Setup git author
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- uses: Swatinem/rust-cache@v2
- name: Setup cargo release
run: cargo install cargo-release
- name: Publish to crate.io
run: cargo release --no-tag -vv --execute --no-confirm ${{ needs.draft_release.outputs.version_name }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: release-drafter/release-drafter@v6
with:
publish: true
tag: ${{ needs.draft_release.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload_assets:
strategy:
fail-fast: false
matrix:
job:
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: junit2json
- os: ubuntu-20.04
target: wasm32-wasi
bin: junit2json.wasm
- os: macos-14
target: x86_64-apple-darwin
bin: junit2json
- os: macos-14
target: aarch64-apple-darwin
bin: junit2json
name: Upload assets ${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
if: github.event_name == 'workflow_dispatch'
needs: ["draft_release", "publish_release"]
steps:
- uses: actions/checkout@v4
- name: Setup rust build target
run: rustup target add ${{ matrix.job.target }}
- name: Build
run: |
if [[ "${{ matrix.job.target }}" == "wasm32-wasi" ]]; then
cargo install cargo-wasi
cargo wasi build --release --target ${{ matrix.job.target }}
else
cargo build --release --target ${{ matrix.job.target }}
fi
- name: Upload assets
run: |
ASSET_NAME="junit2json-rs-${{ needs.draft_release.outputs.version_name }}-${{ matrix.job.target}}.tar.gz"
cp target/${{ matrix.job.target }}/release/${{ matrix.job.bin }} ./${{ matrix.job.bin }}
tar -zcvf "${ASSET_NAME}" ${{ matrix.job.bin }}
gh release upload ${{ needs.draft_release.outputs.tag_name }} "${ASSET_NAME}" --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}