-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (128 loc) · 4.08 KB
/
release.yml
File metadata and controls
144 lines (128 loc) · 4.08 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
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
# .github/workflows/release.yml
on:
push:
tags:
- "v*"
jobs:
build-release:
name: deploy
permissions:
contents: write
id-token: write
attestations: write
runs-on: ${{ matrix.os }}
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
CARGO: cargo
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
TARGET_FLAGS: ""
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
build:
- linux
- macos
- windows
include:
- build: linux
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-musl
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-musl
- build: macos
os: macos-15
rust: stable
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-15
rust: stable
target: aarch64-apple-darwin
- build: windows
os: ubuntu-22.04
rust: stable
target: x86_64-pc-windows-gnu
- build: windows-32
os: ubuntu-22.04
rust: stable
target: i686-pc-windows-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Use Cross
shell: bash
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/screenly"
- name: Package
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ matrix.build }}" == windows* ]]; then
zip ../../../screenly-cli-${{ matrix.target }}.zip screenly.exe
else
tar czvf ../../../screenly-cli-${{ matrix.target }}.tar.gz screenly
fi
cd -
- name: Publish
uses: softprops/action-gh-release@v1
# TODO: if any of the build step fails, the release should be deleted.
with:
files: "screenly*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-path: "${{ github.workspace }}/screenly*"
build-docker-image:
environment: master
name: docker
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build container
run: |
docker build . \
--build-arg "RELEASE=$GITHUB_REF_NAME" \
-t "screenly/cli:$GITHUB_REF_NAME"
- name: Tag container
run: |
docker tag \
"screenly/cli:$GITHUB_REF_NAME" \
"screenly/cli:latest"
- name: Login to DockerHub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker containers
run: |
docker push "screenly/cli:$GITHUB_REF_NAME"
docker push "screenly/cli:latest"