Skip to content

Commit 8a65a77

Browse files
authored
Refactor CI and dev workflow with buildx bake (#161)
Co-authored-by: CrazyMax <[email protected]>
1 parent da276e6 commit 8a65a77

27 files changed

+486
-363
lines changed

.dockerignore

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
/.idea
22
/*.iml
33

4-
/.dev
5-
/.git
6-
/.github
7-
/.res
4+
.dev
85
/bin
96
/dist
10-
/docs
11-
/.editorconfig
12-
/.gitignore
13-
/.goreleaser.yml
14-
/CHANGELOG.md
15-
/LICENSE
16-
/README.md
7+
/site
8+
/coverage.txt

.github/CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
Hi there! I'm thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
44

5-
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](../LICENSE).
5+
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license)
6+
to the public under the [project's open source license](../LICENSE).
67

78
## Submitting a pull request
89

910
1. [Fork](https://github.com/crazy-max/ftpgrab/fork) and clone the repository
1011
2. Configure and install the dependencies: `go mod download`
1112
3. Create a new branch: `git checkout -b my-branch-name`
12-
4. Make your change
13-
5. Test your code: `go test -covermode=atomic ./...`
14-
6. Build with [GoReleaser](https://goreleaser.com/): `goreleaser release --skip-publish --skip-validate --rm-dist`
15-
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ftpgrab/compare)
16-
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
13+
4. Make your changes
14+
5. Validate: `docker buildx bake validate`
15+
6. Test your code: `docker buildx bake test`
16+
7. Build the project: `docker buildx bake artifact-all image-all`
17+
8. Push to your fork and [submit a pull request](https://github.com/crazy-max/ftpgrab/compare)
18+
9. Pat your self on the back and wait for your pull request to be reviewed and merged.
1719

1820
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
1921

@@ -25,5 +27,5 @@ Here are a few things you can do that will increase the likelihood of your pull
2527
## Resources
2628

2729
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
28-
* [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
29-
* [GitHub Help](https://help.github.com)
30+
* [Using Pull Requests](https://docs.github.com/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
31+
* [GitHub Help](https://docs.github.com)

.github/dependabot.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ updates:
1010
labels:
1111
- ":game_die: dependencies"
1212
- ":robot: bot"
13-
- package-ecosystem: "docker"
14-
open-pull-requests-limit: 10
15-
directory: "/docs"
16-
schedule:
17-
interval: "daily"
18-
time: "08:00"
19-
timezone: "Europe/Paris"
20-
labels:
21-
- ":game_die: dependencies"
22-
- ":robot: bot"
2313
- package-ecosystem: "github-actions"
2414
open-pull-requests-limit: 10
2515
directory: "/"

.github/workflows/build.yml

Lines changed: 54 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- 'master'
7-
- 'v*'
87
tags:
98
- 'v*'
109
paths-ignore:
@@ -15,81 +14,48 @@ on:
1514
pull_request:
1615
branches:
1716
- 'master'
18-
- 'v*'
1917
paths-ignore:
2018
- '**.md'
2119
- '.github/workflows/docs.yml'
2220
- 'docs/**'
2321
- 'mkdocs.yml'
2422

23+
env:
24+
DOCKERHUB_SLUG: crazymax/ftpgrab
25+
GHCR_SLUG: ghcr.io/crazy-max/ftpgrab
26+
2527
jobs:
26-
go:
28+
test:
2729
runs-on: ubuntu-latest
2830
steps:
2931
-
3032
name: Checkout
3133
uses: actions/checkout@v2
32-
-
33-
name: Prepare
34-
id: prep
35-
run: |
36-
if [[ $GITHUB_REF == refs/tags/* ]]; then
37-
echo ::set-output name=tag_name::${GITHUB_REF#refs/tags/}
38-
fi
39-
-
40-
name: Set up Go
41-
uses: actions/setup-go@v2
4234
with:
43-
go-version: 1.15
35+
fetch-depth: 0
4436
-
45-
name: Cache Go modules
46-
uses: actions/cache@v2
47-
with:
48-
path: ~/go/pkg/mod
49-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
50-
restore-keys: |
51-
${{ runner.os }}-go-
52-
-
53-
name: GoReleaser
54-
uses: goreleaser/goreleaser-action@v2
55-
with:
56-
version: latest
57-
args: release --skip-publish --rm-dist
37+
name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v1
5839
-
5940
name: Test
60-
run: |
61-
go test -coverprofile=coverage.txt -covermode=atomic ./...
41+
uses: docker/bake-action@v1
42+
with:
43+
targets: test
6244
-
6345
name: Upload coverage
6446
uses: codecov/codecov-action@v1
65-
if: success()
6647
with:
67-
token: ${{ secrets.CODECOV_TOKEN }}
6848
file: ./coverage.txt
69-
-
70-
name: GitHub Release
71-
uses: softprops/action-gh-release@v1
72-
if: startsWith(github.ref, 'refs/tags/')
73-
with:
74-
draft: true
75-
files: |
76-
dist/checksums.txt
77-
dist/*.tar.gz
78-
dist/*.zip
79-
name: ${{ steps.prep.outputs.tag_name }}
80-
env:
81-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8249

83-
docker:
50+
build:
8451
runs-on: ubuntu-latest
85-
needs: go
86-
env:
87-
DOCKERHUB_SLUG: crazymax/ftpgrab
88-
GHCR_SLUG: ghcr.io/crazy-max/ftpgrab
52+
needs: [ test ]
8953
steps:
9054
-
9155
name: Checkout
9256
uses: actions/checkout@v2
57+
with:
58+
fetch-depth: 0
9359
-
9460
name: Docker meta
9561
id: docker_meta
@@ -98,17 +64,19 @@ jobs:
9864
images: |
9965
${{ env.DOCKERHUB_SLUG }}
10066
${{ env.GHCR_SLUG }}
67+
tag-semver: |
68+
{{version}}
10169
tag-edge: true
102-
tag-match: v(.*)
103-
tag-match-group: 1
70+
label-custom: |
71+
org.opencontainers.image.title=FTPGrab
72+
org.opencontainers.image.description=Grab your files periodically from a remote FTP or SFTP server easily
73+
org.opencontainers.image.vendor=CrazyMax
10474
-
10575
name: Set up QEMU
10676
uses: docker/setup-qemu-action@v1
10777
-
10878
name: Set up Docker Buildx
10979
uses: docker/setup-buildx-action@v1
110-
with:
111-
buildkitd-flags: "--debug"
11280
-
11381
name: Login to DockerHub
11482
if: github.event_name != 'pull_request'
@@ -125,21 +93,41 @@ jobs:
12593
username: ${{ secrets.GHCR_USERNAME }}
12694
password: ${{ secrets.GHCR_TOKEN }}
12795
-
128-
name: Build
129-
uses: docker/build-push-action@v2
96+
name: Build artifacts
97+
uses: docker/bake-action@v1
13098
with:
131-
context: .
132-
file: ./Dockerfile
133-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
99+
targets: artifact-all
100+
-
101+
name: Move artifacts
102+
run: |
103+
mv ./dist/**/* ./dist/
104+
-
105+
name: Upload artifacts
106+
uses: actions/upload-artifact@v2
107+
with:
108+
name: ftpgrab
109+
path: ./dist/*
110+
if-no-files-found: error
111+
-
112+
name: Build image
113+
uses: docker/bake-action@v1
114+
with:
115+
files: |
116+
./docker-bake.hcl
117+
${{ steps.docker_meta.outputs.bake-file }}
118+
targets: image-all
134119
push: ${{ github.event_name != 'pull_request' }}
135-
tags: ${{ steps.docker_meta.outputs.tags }}
136-
build-args: |
137-
VERSION=${{ steps.docker_meta.outputs.version }}
138-
labels: |
139-
${{ steps.docker_meta.outputs.labels }}
140-
org.opencontainers.image.title=FTPGrab
141-
org.opencontainers.image.description=Grab your files periodically from a remote FTP or SFTP server easily
142-
org.opencontainers.image.vendor=CrazyMax
120+
-
121+
name: GitHub Release
122+
uses: softprops/action-gh-release@v1
123+
if: startsWith(github.ref, 'refs/tags/')
124+
with:
125+
draft: true
126+
files: |
127+
dist/*.tar.gz
128+
dist/*.zip
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143131
-
144132
name: Check manifest
145133
if: github.event_name != 'pull_request'

.github/workflows/docs.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- 'master'
7-
- 'v*'
87
tags:
98
- 'v*'
109
paths:
@@ -15,7 +14,6 @@ on:
1514
pull_request:
1615
branches:
1716
- 'master'
18-
- 'v*'
1917
paths:
2018
- '.github/workflows/docs.yml'
2119
- 'docs/**'
@@ -32,35 +30,21 @@ jobs:
3230
with:
3331
fetch-depth: 0
3432
-
35-
name: Prepare
36-
id: prep
37-
run: |
38-
VERSION=edge
39-
RELEASE=false
40-
if [[ $GITHUB_REF == refs/tags/* ]]; then
41-
VERSION=${GITHUB_REF#refs/tags/v}
42-
fi
43-
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
44-
RELEASE=true
45-
fi
46-
echo ::set-output name=release::${RELEASE}
47-
-
48-
name: Build mkdocs Docker image
49-
run: |
50-
docker build -t mkdocs -f ./docs/Dockerfile ./
33+
name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v1
5135
-
5236
name: Build docs
53-
run: |
54-
docker run --rm -v "$(pwd):/docs" mkdocs build --strict
55-
sudo chown -R $(id -u):$(id -g) ./site
37+
uses: docker/bake-action@v1
38+
with:
39+
targets: docs
5640
-
5741
name: Check GitHub Pages status
5842
uses: crazy-max/ghaction-github-status@v2
5943
with:
6044
pages_threshold: major_outage
6145
-
6246
name: Deploy
63-
if: github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || steps.prepare.outputs.release == 'true')
47+
if: github.event_name != 'pull_request'
6448
uses: crazy-max/ghaction-github-pages@v2
6549
with:
6650
target_branch: gh-pages

.github/workflows/gosum.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)