Skip to content

Commit ec541b7

Browse files
committed
add release action
1 parent 5b36392 commit ec541b7

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create-release:
10+
name: create-github-release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- id: create_release
14+
uses: ncipollo/release-action@v1
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
draft: false
18+
prerelease: false
19+
- run: |
20+
echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
21+
- uses: actions/upload-artifact@v4
22+
with:
23+
name: release_url
24+
path: release_url.txt
25+
26+
publish-release:
27+
needs: [create-release]
28+
name: upload-release-asset-${{ matrix.os }}-${{ matrix.arch }}
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- os: windows-latest
35+
name: win
36+
arch: x64
37+
- os: macos-latest
38+
name: macos
39+
arch: aarch64
40+
- os: ubuntu-latest
41+
name: linux
42+
arch: x64
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: actions-rust-lang/setup-rust-toolchain@v1
46+
with:
47+
toolchain: 'stable'
48+
- id: get_version
49+
uses: actions/github-script@v7
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
result-encoding: string
53+
script: |
54+
return 'mdbook-inpage-tab-'+context.payload.ref.replace(/refs\/tags\//, '')+'-${{ matrix.name }}-${{ matrix.arch }}';
55+
56+
- run: cargo build --release
57+
- run: Compress-Archive -Path target/release/mdbook-inpage-tab.exe -DestinationPath assets.zip
58+
if: ${{ matrix.os == 'windows-latest' }}
59+
- run: |
60+
cp target/release/mdbook-inpage-tab mdbook-inpage-tab
61+
tar -zcvf assets.tar.gz mdbook-inpage-tab
62+
if: ${{ matrix.os != 'windows-latest'}}
63+
64+
- uses: actions/download-artifact@v4
65+
with:
66+
name: release_url
67+
- id: get_release_info
68+
uses: juliangruber/read-file-action@v1
69+
with:
70+
path: release_url.txt
71+
- uses: shogo82148/actions-upload-release-asset@v1
72+
with:
73+
github_token: ${{ secrets.GITHUB_TOKEN }}
74+
upload_url: ${{ steps.get_release_info.outputs.content }}
75+
asset_path: ./assets.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
76+
asset_name: ${{ steps.get_version.outputs.result }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
77+
asset_content_type: ${{ matrix.os == 'windows-latest' && 'application/zip' || 'application/octet-stream' }}

0 commit comments

Comments
 (0)