-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (146 loc) · 4.87 KB
/
Copy pathpublish-mows-cli.yml
File metadata and controls
165 lines (146 loc) · 4.87 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Publish mows binary
on:
push:
tags:
- 'mows-cli-v*'
paths:
- 'utils/mows-cli/**'
- 'utils/mows-common-rust/**'
- '.github/workflows/publish-mows-cli.yml'
pull_request:
paths:
- 'utils/mows-cli/**'
- 'utils/mows-common-rust/**'
- '.github/workflows/publish-mows-cli.yml'
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (do not publish release)'
required: false
default: 'false'
type: boolean
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Install Rust
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable
- name: Cache cargo registry
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
utils/mows-cli/target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('utils/mows-cli/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-test-
- name: Run unit tests
run: |
cd utils/mows-cli
cargo test --release
- name: Build release binary for e2e tests
run: |
cd utils/mows-cli
cargo build --release
- name: Create mpm symlink for e2e tests
run: |
ln -sf mows utils/mows-cli/target/release/mpm
- name: Run e2e tests
run: |
cd utils/mows-cli/tests
# Use mock Docker client for tests that would otherwise need Docker daemon
# Skip test-self-update which requires network access to GitHub API
SKIP_TESTS="test-self-update" ./run-all.sh
env:
MOWS_BIN: ${{ github.workspace }}/utils/mows-cli/target/release/mows
MPM_BIN: ${{ github.workspace }}/utils/mows-cli/target/release/mpm
MPM_MOCK_DOCKER: "1"
build:
needs: test
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
os_name: linux
- arch: arm64
os_name: linux
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Get git info
id: git_info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cs)" >> $GITHUB_OUTPUT
- name: Build static binary using Docker
env:
GIT_HASH: ${{ steps.git_info.outputs.hash }}
GIT_DATE: ${{ steps.git_info.outputs.date }}
TARGETARCH: ${{ matrix.arch }}
BUILDX_CACHE: gha
run: |
cd utils/mows-cli
bash build.sh
- name: Get version from tag
id: get_version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#mows-cli-v}"
else
VERSION="dev"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Rename binary with version and platform
run: |
cd utils/mows-cli/dist
# Remove symlink, keep only the real binary
rm -f mpm
mv mows mows-${{ steps.get_version.outputs.version }}-${{ matrix.os_name }}-${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: mows-${{ matrix.os_name }}-${{ matrix.arch }}
path: utils/mows-cli/dist/mows-*
retention-days: 7
release:
needs: build
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && github.event.inputs.dry_run != 'true'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
path: artifacts
merge-multiple: true
- name: Get version from tag
id: get_version
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#mows-cli-v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Create checksums
run: |
cd artifacts
for f in mows-*; do
sha256sum "$f" > "${f}-checksum-sha256.txt"
done
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
with:
name: mows v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
files: |
artifacts/mows-*
generate_release_notes: true