Skip to content

Commit 6a36d03

Browse files
authored
Merge pull request #78 from r-Norge/dev
Fix cli
2 parents c9973ec + 02d9ac9 commit 6a36d03

File tree

1 file changed

+104
-43
lines changed

1 file changed

+104
-43
lines changed

.github/workflows/build.yml

+104-43
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
env:
88
CheckFiles: "bot.py musicbot/"
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111

1212
- name: Set up Python 3.10
13-
uses: actions/setup-python@v4.2.0
13+
uses: actions/setup-python@v4.5.0
1414
with:
1515
python-version: 3.10.7
1616

@@ -27,14 +27,14 @@ jobs:
2727
test:
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131

3232
- name: Set up Python 3.10
33-
uses: actions/setup-python@v4.2.0
33+
uses: actions/setup-python@v4.5.0
3434
with:
3535
python-version: 3.10.7
3636

37-
- name: Install dependencies
37+
- name: Install dependencies
3838
run: |
3939
pip install pytest
4040
pip install -r requirements.txt
@@ -45,57 +45,118 @@ jobs:
4545
4646
build-and-push:
4747
needs: [lint, test]
48+
strategy:
49+
matrix:
50+
architecture: [linux-arm-v7, linux-arm64, linux-amd64]
4851
runs-on: ubuntu-latest
4952
if: github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true'
50-
env:
51-
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
5253

5354
steps:
54-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v3
56+
57+
- name: Set up QEMU
58+
uses: docker/[email protected]
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/[email protected]
62+
with:
63+
install: true
64+
version: latest
65+
driver-opts: image=moby/buildkit:master
66+
67+
- name: Login to DockerHub
68+
uses: docker/[email protected]
69+
with:
70+
username: roxedus
71+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
72+
73+
- name: Login to GitHub Container Registry
74+
uses: docker/[email protected]
75+
with:
76+
registry: ghcr.io
77+
username: ${{ github.actor }}
78+
password: ${{ secrets.GITHUB_TOKEN }}
5579

5680
- name: Create VARS
57-
env:
58-
_repo: rnorge/music
59-
_username: roxedus
60-
_ref: ${{github.ref}}
6181
id: vars
6282
run: |
63-
echo "::set-output name=branch::$(echo ${_ref} | cut -d/ -f3)"
64-
echo "::set-output name=username::$(echo ${_username} | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')"
65-
echo "::set-output name=repo::$(echo ${_repo} | tr '[:upper:]' '[:lower:]')"
83+
ARCHITECTURE=${{ matrix.architecture }}
84+
echo "branch=$(echo ${{github.ref}} | cut -d/ -f3)" >> $GITHUB_OUTPUT
85+
echo "repo=rnorge/music" >> $GITHUB_OUTPUT
86+
echo "platform=${ARCHITECTURE//-/\/}" >> $GITHUB_OUTPUT
87+
echo "ghcr=r-norge/shitemusicbot" >> $GITHUB_OUTPUT
88+
echo "version=$(grep -i bot_version musicbot/utils/bot_version.py | cut -d" " -f3 | tr -d \")" >> $GITHUB_OUTPUT
89+
90+
- name: Build and push
91+
uses: docker/[email protected]
92+
with:
93+
push: true
94+
attests: type=sbom,generator=docker/buildkit-syft-scanner
95+
#sbom: true
96+
provenance: true # https://github.com/docker/buildx/issues/1509
97+
platforms: ${{ steps.vars.outputs.platform }}
98+
build-args: BUILDKIT_SBOM_SCAN_CONTEXT=true,BUILDKIT_SBOM_SCAN_STAGE=true
99+
tags: |
100+
${{ steps.vars.outputs.repo }}:${{ steps.vars.outputs.branch }}-${{github.sha}}-${{ matrix.architecture }}
101+
ghcr.io/${{ steps.vars.outputs.ghcr }}:${{ steps.vars.outputs.branch }}-${{github.sha}}-${{ matrix.architecture }}
102+
103+
publish:
104+
needs: [build-and-push]
105+
runs-on: ubuntu-latest
106+
if: github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true'
66107

67-
- name: Push changed files, and tags
68-
if: github.ref == 'refs/heads/master'
69-
uses: EndBug/add-and-commit@v4
108+
steps:
109+
- uses: actions/checkout@v3
110+
111+
- name: Set up Docker Buildx
112+
uses: docker/[email protected]
70113
with:
71-
add: musicbot/utils/bot_version.py
72-
author_name: MarlinBotCode
73-
message: Bump Version
74-
tag: v${{ steps.tagger.outputs.tag }}
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
install: true
115+
version: latest
116+
driver-opts: image=moby/buildkit:master
77117

78-
- name: Build the Docker image
79-
env:
80-
REPO: ${{ steps.vars.outputs.repo }}
81-
BRANCH: ${{ steps.vars.outputs.branch }}
118+
- name: Login to DockerHub
119+
uses: docker/[email protected]
120+
with:
121+
username: roxedus
122+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
123+
124+
- name: Login to GitHub Container Registry
125+
uses: docker/[email protected]
126+
with:
127+
registry: ghcr.io
128+
username: ${{ github.actor }}
129+
password: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Create VARS
132+
id: vars
82133
run: |
83-
docker build -t $REPO:$BRANCH -t $REPO:$BRANCH-${{github.sha}} .
134+
echo "branch=$(echo ${{github.ref}} | cut -d/ -f3)" >> $GITHUB_OUTPUT
135+
echo "repo=rnorge/music" >> $GITHUB_OUTPUT
136+
echo "ghcr=r-norge/shitemusicbot" >> $GITHUB_OUTPUT
137+
echo "version=$(grep -i bot_version musicbot/utils/bot_version.py | cut -d" " -f3 | tr -d \")" >> $GITHUB_OUTPUT
84138
85-
- name: Master tag
86-
if: github.ref == 'refs/heads/master'
139+
- name: Create manifests for DockerHub
87140
env:
88-
REPO: ${{ steps.vars.outputs.repo }}
89-
BRANCH: ${{ steps.vars.outputs.branch }}
141+
DOCKER_CLI_EXPERIMENTAL: enabled
90142
run: |
91-
docker tag $REPO:$BRANCH $REPO:${{ steps.tagger.outputs.tag }}
92-
93-
- name: Login to registry
94-
if: github.event_name != 'pull_request'
95-
run: echo $DOCKER_PASSWORD | docker login -u ${{ steps.vars.outputs.username }} --password-stdin
96-
97-
- name: Pushes the Docker image
143+
IMAGE=${{ steps.vars.outputs.repo }}
144+
TAG=${{ steps.vars.outputs.branch }}-${{github.sha}}
145+
SOURCE=${IMAGE}:${TAG}
146+
docker buildx imagetools create -t ${SOURCE} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
147+
docker buildx imagetools create -t ${IMAGE}:${{ steps.vars.outputs.branch }} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
148+
if [[ ${GITHUB_REF//refs\/heads\//} == master ]]; then
149+
docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
150+
fi
151+
- name: Create manifests for GitHub Container Registry
98152
env:
99-
REPO: ${{ steps.vars.outputs.repo }}
100-
if: github.event_name != 'pull_request'
101-
run: docker push -a $REPO
153+
DOCKER_CLI_EXPERIMENTAL: enabled
154+
run: |
155+
IMAGE=ghcr.io/${{ steps.vars.outputs.ghcr }}
156+
TAG=${{ steps.vars.outputs.branch }}-${{github.sha}}
157+
SOURCE=${IMAGE}:${TAG}
158+
docker buildx imagetools create -t ${SOURCE} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
159+
docker buildx imagetools create -t ${IMAGE}:${{ steps.vars.outputs.branch }} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
160+
if [[ ${GITHUB_REF//refs\/heads\//} == master ]]; then
161+
docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
162+
fi

0 commit comments

Comments
 (0)