-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (170 loc) · 5.79 KB
/
publish.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Release
on:
workflow_dispatch:
inputs:
prerelease:
description: |
The semantic version pre-release string.
E.g. in `v1.2.3-beta.2` the pre-release string is `beta.3`.
required: false
push:
tags:
- "*"
defaults:
run:
shell: bash
jobs:
setup:
name: Get release parameters
outputs:
SEMANTIC_VERSION: ${{ steps.params.outputs.SEMANTIC_VERSION }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get release parameters
id: params
run: |
# Get the release version:
IDL2JSON_CARGO_VERSION="$(cargo metadata --locked | jq -r '.packages[] | select(.name == "idl2json") | .version')"
PRERELEASE="${{ github.event.inputs.prerelease }}"
SEMANTIC_VERSION="${IDL2JSON_CARGO_VERSION}${PRERELEASE:+-}${PRERELEASE}"
GIT_TAG="v$SEMANTIC_VERSION"
# Verify that there isn't already a tag for this version
if COMMIT="$(git show-ref "refs/tags/$GIT_TAG")" ; then
if [[ "$GIT_TAG" == "$GITHUB_SHA" ]]
then echo "Tag $GIT_TAG already exists on this commit."
else echo "ERROR: Tag $GIT_TAG already exists and points to a different commit."
exit 1
fi
else
echo "Tagging commit $GITHUB_SHA with $GIT_TAG..."
git tag "$GIT_TAG"
git push origin "refs/tags/$GIT_TAG"
fi
(
for var in IDL2JSON_CARGO_VERSION PRERELEASE SEMANTIC_VERSION GIT_TAG ; do
echo "$var=${!var}"
done
) | tee -a $GITHUB_OUTPUT
#- Tag, if there isn't one already on this commit
#- name: Create a draft release if there isn't one already
build:
name: Release binary for ${{ matrix.name }}
needs: setup
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: linux
target_dir: target/x86_64-unknown-linux-musl/release/
asset_name: idl2json_cli-x86_64-unknown-linux-musl.tar.gz
old_name: idl2json-linux-x86_64.tar.gz
make_target: musl-static
build: musl
pack: tar
# - os: windows-latest
# name: windows
# target_dir: target/release/
# asset_name: idl2json-windows-x86_64
# make_target: release
# rust: 1.60.0
- os: macos-latest
name: macos
target_dir: target/release/
asset_name: idl2json_cli-x86_64-apple-darwin.zip
old_name: idl2json-macos-x86_64.zip
make_target: release
rust: 1.60.0
build: cargo
pack: zip
# - os: ubuntu-latest
# name: arm
# target_file: target/arm-unknown-linux-gnueabihf/release/{idl2json,yaml2candid}
# asset_name: idl2json-arm_32
# make_target: unused
# rust: 1.60.0
steps:
- name: Stop, we are just testing
run: |
echo SEMANTIC_VERSION="${{ needs.setup.outputs.SEMANTIC_VERSION }}"
false
- uses: actions/checkout@v4
# BUILD
- name: Static build with musl
if: matrix.build == 'musl'
uses: mariodfinity/rust-musl-action@master
with:
args: make ${{ matrix.make_target }}
- name: Install toolchain (ARM)
if: matrix.name == 'arm'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
target: arm-unknown-linux-gnueabihf
- name: Build with cargo
if: matrix.build == 'cargo'
run: make ${{ matrix.make_target }}
- name: Cross build
if: matrix.name == 'arm'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target arm-unknown-linux-gnueabihf --features static-ssl --release --locked
# ZIP
- name: tar the results
if: matrix.pack == 'tar'
run: |
tar -C "${{ matrix.target_dir }}" -czvf "$PWD/${{ matrix.asset_name }}" idl2json yaml2candid
- name: zip the results
if: matrix.pack == 'zip'
run: |
zipfile="$PWD/${{ matrix.asset_name }}"
cd "${{ matrix.target_dir }}"
zip "$zipfile" idl2json yaml2candid
- name: Support the old download location
run: cp "${{ matrix.asset_name }}" "${{ matrix.old_name }}"
# UPLOAD
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "${{ matrix.asset_name }}"
tag: "${{ github.ref }}"
publish_idl2json:
needs: build
name: Publish idl2json to crates.io
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: idl2json
steps:
- uses: actions/checkout@v4
- name: Publish ${{ matrix.package }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p "${{ matrix.package }}"
publish_idl2json_cli:
needs: publish_idl2json
name: Publish idl2json_cli to crates.io
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- package: idl2json_cli
steps:
- uses: actions/checkout@v4
- name: Publish ${{ matrix.package }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p "${{ matrix.package }}"