-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (128 loc) · 4.97 KB
/
ci.yaml
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
# Copyright 2024 Jeremy Edwards
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
on:
push:
tags: ["v*"]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
id-token: write
timeout-minutes: 30
steps:
# https://github.community/t/how-to-get-just-the-tag-name/16241/6
- name: Get the version
id: get_version
run: |
echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3 | cut -d v -f 2)" >> $GITHUB_OUTPUT
echo "build_date=$(date -u +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Install Compilers
run: sudo apt-get install -y mingw-w64 g++-aarch64-linux-gnu libc6-dev-arm64-cross
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout Code
uses: actions/checkout@v4
# https://github.com/docker/login-action#github-packages-docker-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/login-action#github-packages-docker-registry
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "x86_64-unknown-linux-gnu,x86_64-pc-windows-gnu"
components: rustfmt, clippy
- name: Format Check
run: cargo fmt --check
- name: Build
run: make all -j2
- name: Test
run: make test
- name: Annotate commit with clippy warnings
uses: giraffate/clippy-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
version: '0.15.0'
args: '-- --test-threads 1'
- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Container Images
uses: docker/build-push-action@v5
with:
push: ${{ startsWith(github.ref, 'refs/tags/') }}
file: ./Dockerfile
tags: |
docker.io/${{ github.actor }}/filetool:canary
docker.io/${{ github.actor }}/filetool:0.3.1
docker.io/${{ github.actor }}/filetool:${{ github.sha }}
docker.io/${{ github.actor }}/filetool:${{ github.run_id }}
docker.io/${{ github.actor }}/filetool:${{ steps.get_version.outputs.build_date }}
ghcr.io/${{ github.actor }}/filetool:canary
ghcr.io/${{ github.actor }}/filetool:0.3.1
ghcr.io/${{ github.actor }}/filetool:${{ github.sha }}
ghcr.io/${{ github.actor }}/filetool:${{ github.run_id }}
ghcr.io/${{ github.actor }}/filetool:${{ steps.get_version.outputs.build_date }}
labels: |
org.opencontainers.image.title=Filetool
org.opencontainers.image.description=A tool to manage and cleanup files on your hard drive.
org.opencontainers.image.vendor=${{ github.actor }}
org.opencontainers.image.authors=${{ github.actor }}
org.opencontainers.image.version=0.3.1
org.opencontainers.image.url=${{ github.event.repository.clone_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.get_version.outputs.build_timestamp }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Cleanup
run: rm -f cobertura.xml
- name: Publish Crate
if: startsWith(github.ref, 'refs/tags/')
run: |
cargo publish
# https://doc.rust-lang.org/cargo/reference/config.html?highlight=CARGO_REGISTRY_TOKEN#credentials
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
draft: false
prerelease: false
files: |
LICENSE
target/x86_64-unknown-linux-gnu/release/filetool
target/x86_64-pc-windows-gnu/release/filetool.exe