-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (103 loc) · 4.05 KB
/
create-artifacts.yml
File metadata and controls
106 lines (103 loc) · 4.05 KB
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
name: Publish Image
on:
workflow_call:
inputs:
version:
required: true
type: string
jobs:
build-for-os:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos-x86, macos-aarch64]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- build: macos-x86
os: macos-latest
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('ci/cache-version') }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('ci/cache-version') }}-
${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('ci/cache-version') }}-
${{ runner.os }}-${{ matrix.target }}-
- name: Install correct version of Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.target }}
override: true
- name: Configure version and MacOs
if: matrix.os == 'macos-latest'
run: |
mkdir ~/bin
curl --location https://github.com/ethankhall/crom/releases/download/v0.4.2/crom-v0.4.2-darwin-x86_64.tgz | tar -xvz -C ~/bin
chmod +x ~/bin/crom
~/bin/crom write-version custom ${{ inputs.version }}
brew install binutils
echo "$(brew --prefix)/opt/binutils/bin" >> $GITHUB_PATH
- name: Configure version and Linux
if: matrix.os == 'ubuntu-latest'
run: |
docker login docker.pkg.github.com --username ethankhall --password ${{ secrets.GITHUB_TOKEN }}
docker run --rm -v $(pwd):/target docker.pkg.github.com/ethankhall/crom/cli:latest write-version custom ${{ inputs.version }}
- uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --release --target "${{ matrix.target }}"
- run: |
ls target/${{ matrix.target }}/*
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
if-no-files-found: error
path: |
target/${{ matrix.target }}/release/toolup
target/${{ matrix.target }}/release/toolup-shim
release:
runs-on: ubuntu-latest
needs: build-for-os
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: aarch64-apple-darwin
path: artifacts/aarch64-apple-darwin
- uses: actions/download-artifact@v3
with:
name: x86_64-apple-darwin
path: artifacts/x86_64-apple-darwin
- uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-gnu
path: artifacts/x86_64-unknown-linux-gnu
- name: Create release
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
ls artifacts/*/*
mkdir artifacts-to-publish
tar -czv --strip-components 1 --owner=0 --group=0 --no-same-owner -f artifacts-to-publish/toolup-${{ inputs.version }}-linux-gnu-x86_64.tgz -C artifacts/x86_64-unknown-linux-gnu toolup toolup-shim
tar -czv --strip-components 1 --owner=0 --group=0 --no-same-owner -f artifacts-to-publish/toolup-${{ inputs.version }}-darwin-aarch64.tgz -C artifacts/aarch64-apple-darwin toolup toolup-shim
tar -czv --strip-components 1 --owner=0 --group=0 --no-same-owner -f artifacts-to-publish/toolup-${{ inputs.version }}-darwin-x86_64.tgz -C artifacts/x86_64-apple-darwin toolup toolup-shim
gh release upload ${{ inputs.version }} artifacts-to-publish/*