-
Notifications
You must be signed in to change notification settings - Fork 26
154 lines (148 loc) · 4.89 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
name: release
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
env:
PYTHON_STANDALONE_VERSIONS: |
[
"20240415"
]
PYTHON_VERSIONS: |
[
"3.10.14",
"3.11.9",
"3.12.3"
]
jobs:
build-matrix:
runs-on: ubuntu-latest
outputs:
PYTHON_STANDALONE_VERSIONS: ${{ env.PYTHON_STANDALONE_VERSIONS }}
PYTHON_VERSIONS: ${{ env.PYTHON_VERSIONS }}
steps:
- name: noop
run: |
echo noop
build-tag:
needs:
- build-matrix
strategy:
matrix:
pythonStandaloneVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_STANDALONE_VERSIONS) }}
pythonVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_VERSIONS) }}
fail-fast: false
runs-on: ubuntu-22.04
steps:
- name: clone
run: |
# can't use actions/checkout here as transferring the shallow clone fails when using upload-/download-artifact
git clone https://github.com/$GITHUB_REPOSITORY . --depth=1
- name: checkout PR
if: ${{ github.event_name == 'pull_request' }}
run: |
echo fetching pull/${{ github.ref_name }}
git fetch origin pull/${{ github.ref_name }}:pr --depth=1
git checkout pr
- name: checkout branch
if: ${{ github.event_name == 'push' }}
run: |
echo fetching ${{ github.ref_name }}
git fetch origin ${{ github.ref_name }} --depth=1
git checkout ${{ github.ref_name }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-${{ matrix.pythonStandaloneVersion }}-${{ matrix.pythonVersion }}-build-tag-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.pythonStandaloneVersion }}-${{ matrix.pythonVersion }}-build-tag-
- name: build-tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "go-embed-python releaser"
BUILD_NUM=$(./hack/next-build-num.sh ${{ matrix.pythonStandaloneVersion }} ${{ matrix.pythonVersion }})
./hack/build-tag.sh ${{ matrix.pythonStandaloneVersion }} ${{ matrix.pythonVersion }} $BUILD_NUM
echo $BUILD_NUM > build-num
- name: git gc
run: |
git gc
- uses: actions/upload-artifact@v4
with:
name: workdir-${{ matrix.pythonStandaloneVersion }} ${{ matrix.pythonVersion }}
path: |
.git
build-num
tests:
needs:
- build-matrix
- build-tag
strategy:
matrix:
os:
- ubuntu-22.04
- macos-12
- windows-2019
pythonStandaloneVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_STANDALONE_VERSIONS) }}
pythonVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_VERSIONS) }}
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-${{ matrix.pythonStandaloneVersion }}-${{ matrix.pythonVersion }}-tests-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.pythonStandaloneVersion }}-${{ matrix.pythonVersion }}-tests-
- uses: actions/download-artifact@v4
with:
name: workdir-${{ matrix.pythonStandaloneVersion }} ${{ matrix.pythonVersion }}
- name: checkout tag
shell: bash
run: |
git reset --hard
git checkout v0.0.0-${{ matrix.pythonVersion }}-${{ matrix.pythonStandaloneVersion }}-$(cat build-num)
- name: run tests
shell: bash
run: |
go test ./... -v
release:
needs:
- build-matrix
- tests
strategy:
matrix:
pythonStandaloneVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_STANDALONE_VERSIONS) }}
pythonVersion: ${{ fromJSON(needs.build-matrix.outputs.PYTHON_VERSIONS) }}
fail-fast: false
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
permissions:
contents: write
actions: write
steps:
- uses: actions/download-artifact@v4
with:
name: workdir-${{ matrix.pythonStandaloneVersion }} ${{ matrix.pythonVersion }}
- name: update remote url
run: |
git remote set-url origin https://token:[email protected]/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: push tag
run: |
git push origin v0.0.0-${{ matrix.pythonVersion }}-${{ matrix.pythonStandaloneVersion }}-$(cat build-num)