Skip to content

Commit bbf9d2b

Browse files
committed
Rewrite release action file
1 parent 6412720 commit bbf9d2b

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,74 @@ on:
44
tags:
55
- '*'
66

7-
name: Create Release
8-
9-
env:
10-
RELEASE_BIN: ckb-debugger
11-
12-
RELEASE_ADDS: README.md LICENSE
13-
14-
157
jobs:
16-
build:
17-
name: Build release
18-
19-
runs-on: ${{ matrix.os }}
20-
strategy:
21-
matrix:
22-
build: [linux, macos]
23-
# build: [linux, macos, windows]
24-
include:
25-
- build: linux
26-
os: ubuntu-latest
27-
rust: 1.46.0
28-
- build: macos
29-
os: macos-latest
30-
rust: 1.46.0
31-
# - build: windows
32-
# os: windows-latest
33-
# rust: 1.46.0
34-
8+
release:
9+
name: Create Release
10+
runs-on: ubuntu-latest
3511
steps:
36-
- uses: actions/checkout@v1
12+
# Reference: https://github.community/t/how-to-get-just-the-tag-name/16241/6
13+
- name: Get the version
14+
id: get_version
15+
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ steps.get_version.outputs.VERSION }}
23+
release_name: Release ${{ steps.get_version.outputs.VERSION }}
24+
draft: false
25+
prerelease: false
26+
- name: Output upload URL file
27+
run: echo "${{ steps.create_release.outputs.upload_url }}" > upload_url.txt
28+
- name: Save upload URL file
29+
uses: actions/upload-artifact@v1
30+
with:
31+
name: upload_url
32+
path: upload_url.txt
3733

38-
- name: Install windows dependencies (scoop)
34+
publish-linux:
35+
name: Publish binary on Linux
36+
needs: [release]
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Load upload URL file
40+
uses: actions/download-artifact@v1
41+
with:
42+
name: upload_url
43+
- name: Get upload URL
44+
id: get_upload_url
3945
run: |
40-
iwr -useb get.scoop.sh | iex
41-
scoop install llvm
42-
echo "LIBCLANG_PATH=$($HOME)/scoop/apps/llvm/current/bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
43-
if: matrix.os == 'windows-latest'
44-
46+
value=`cat upload_url/upload_url.txt`
47+
echo ::set-output name=upload_url::$value
48+
env:
49+
TAG_REF_NAME: ${{ github.ref }}
50+
REPOSITORY_NAME: ${{ github.repository }}
51+
- uses: actions/checkout@v2
4552
- name: Build
46-
run: cd bins && cargo build --verbose --release
47-
48-
- name: Create artifact directory
49-
run: mkdir artifacts
50-
51-
- name: Create archive for Linux
52-
run: 7z a -ttar -so -an ./bins/target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ./artifacts/${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz
53-
if: matrix.os == 'ubuntu-latest'
54-
55-
# - name: Create archive for Windows
56-
# run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-windows-x86_64.zip ./bins/target/release/${{ env.RELEASE_BIN }}.exe ${{ env.RELEASE_ADDS }}
57-
# if: matrix.os == 'windows-latest'
58-
59-
- name: Install p7zip
60-
# 7Zip not available on MacOS, install p7zip via homebrew.
61-
run: brew install p7zip
62-
if: matrix.os == 'macos-latest'
63-
64-
- name: Create archive for MacOS
65-
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-mac-x86_64.zip ./bins/target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
66-
if: matrix.os == 'macos-latest'
67-
68-
# This will double-zip
69-
# See - https://github.com/actions/upload-artifact/issues/39
70-
- uses: actions/upload-artifact@v1
71-
name: Upload archive
53+
run: cd bins && cargo build --release
54+
- name: Archive files
55+
run: tar -cvzf ckb-debugger-linux-x64.tar.gz bins/target/release/ckb-debugger LICENSE
56+
- name: Generate checksum
57+
run: sha256sum ckb-debugger-linux-x64.tar.gz > ckb-debugger-linux-x64-sha256.txt
58+
- name: Upload binary
59+
id: upload-release-binary
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ steps.get_upload_url.outputs.upload_url }}
65+
asset_path: ckb-debugger-linux-x64.tar.gz
66+
asset_name: ckb-debugger-linux-x64.tar.gz
67+
asset_content_type: application/tar+gzip
68+
- name: Upload checksum
69+
id: upload-release-checksum
70+
uses: actions/upload-release-asset@v1
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7273
with:
73-
name: ${{ runner.os }}
74-
path: artifacts/
74+
upload_url: ${{ steps.get_upload_url.outputs.upload_url }}
75+
asset_path: ckb-debugger-linux-x64-sha256.txt
76+
asset_name: ckb-debugger-linux-x64-sha256.txt
77+
asset_content_type: text/plain

0 commit comments

Comments
 (0)