-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (144 loc) · 4.79 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
on:
push:
tags:
- '**'
branches:
- main
pull_request:
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build-and-push-docker-image:
name: Build and push docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
GITHUB_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Github Container registry
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Dockerhub Container registry
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build:
name: Build binaries
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.12"
os: ubuntu-20.04
package-suffix: ubuntu-20.04
- python-version: "3.12"
os: ubuntu-latest
package-suffix: ubuntu
- python-version: "3.12"
os: macos-12
package-suffix: macos
- python-version: "3.12"
os: macos-14
package-suffix: macos-arm64
- python-version: "3.12"
os: windows-latest
package-suffix: windows
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev] --extra-index-url https://pypi.chia.net/simple/
- name: Build binary
run: pyinstaller foxy_farmer.spec
- name: Include powershell harvester scripts
if: ${{ matrix.os == 'windows-latest' }}
run: |
copy make_harvester_installer.ps1 dist
copy run_harvester.ps1 dist
- name: Save release archive
uses: actions/upload-artifact@v4
with:
name: foxy-farmer-${{ matrix.package-suffix }}
path: dist/*
publish-github-release:
name: Publish GitHub release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Fetch release archives
uses: actions/download-artifact@v4
- name: Mark binary as executable
run: |
chmod +x foxy-farmer-ubuntu-20.04/foxy-farmer
chmod +x foxy-farmer-ubuntu/foxy-farmer
chmod +x foxy-farmer-macos/foxy-farmer
chmod +x foxy-farmer-macos-arm64/foxy-farmer
- name: Create release zip
run:
for i in foxy-farmer-*/; do zip -r -j "${i%/}.zip" "$i"; done
- name: Get the tag name
id: tag
run: echo TAG=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: warn
version: ${{ steps.tag.outputs.TAG }}
path: ./CHANGELOG.md
- uses: ncipollo/release-action@v1
with:
artifacts: "foxy-farmer-*.zip"
name: "Foxy-Farmer v${{ steps.tag.outputs.TAG }}"
body: ${{ steps.changelog_reader.outputs.changes }}