-
Notifications
You must be signed in to change notification settings - Fork 54
155 lines (132 loc) · 4.6 KB
/
release.yml
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
# This workflow builds Python distribution packages using cibuildwheel tool and
# environment and publishes packages as a part of a GitHub release. Also it
# releases container image to the DockerHub.
# This workflow uses actions that are not certified by GitHub. They are
# provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
name: release
on:
workflow_dispatch:
release:
types: [published]
jobs:
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "macos-13", "macos-14"]
max-parallel: 3
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: |
echo "REF_NAME=${{github.ref_name}}" | tee -a $GITHUB_ENV
echo "EVENT_NAME=${{github.event_name}}" | tee -a $GITHUB_ENV
echo "PRERELEASE=${{github.event.release.prerelease}}" | tee -a $GITHUB_ENV
echo "TAG_NAME=${{github.event.release.tag_name}}" | tee -a $GITHUB_ENV
echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee -a $GITHUB_ENV
- name: Build wheels on ${{ matrix.os }}
if: ${{ !startsWith(matrix.os, 'macos') }}
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}"
with:
package-dir: ./python
- name: Build wheels on ${{ matrix.os }}
if: ${{ startsWith(matrix.os, 'macos') }}
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}"
with:
package-dir: ./python
- name: Publish Artifacts on GitHub Release
if: github.event.action == 'published'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./wheelhouse/*.whl
tag: ${{ github.ref }}
prerelease: ${{ github.event.release.prerelease }}
overwrite: true
file_glob: true
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
publish-test-pypi:
name: Publish to Test PyPI
permissions:
id-token: write
environment:
name: pypi-test
runs-on: ubuntu-latest
needs: [build-wheels]
if: github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: dist
- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-pypi:
name: Publish to PyPI
permissions:
id-token: write
environment:
name: pypi-production
runs-on: ubuntu-latest
needs: [build-wheels]
if: github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-docker:
name: Publish Docker image
environment:
name: dockerhub-production
runs-on: ubuntu-latest
needs: [build-wheels]
if: github.event.action == 'published'
steps:
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
load: true
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
tags: trueagi/hyperon:test
- name: Test
run: |
echo "(* 7 6)" | docker run --rm trueagi/hyperon:test metta-repl
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
tags: |
trueagi/hyperon:${{github.event.release.tag_name}}
trueagi/hyperon:latest