-
Notifications
You must be signed in to change notification settings - Fork 10
133 lines (114 loc) · 4.46 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
name: Auto-release on PR merge
on:
# ATM, this is the closest trigger to a PR merging
push:
branches:
- master
env:
# Pin to v10.28.0, which (as of 2021-05-25) is the latest version with assets
AUTO_VERSION: v11.0.5
jobs:
release-check:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
outputs:
auto-version: ${{ steps.auto-version.outputs.version }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
# A full checkout is required so that auto will have access to tag
# information.
fetch-depth: 0
- name: Download auto
run: |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/tags/$AUTO_VERSION | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
wget -O- "$auto_download_url" | gunzip > ~/auto
chmod a+x ~/auto
- name: Check whether a release is due
id: auto-version
run: |
version="$(~/auto version)"
echo "version=$version" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
runs-on: ubuntu-latest
needs: release-check
if: needs.release-check.outputs.auto-version != ''
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
path: dandischema
token: ${{ secrets.DANDI_GITHUB_TOKEN }}
- name: Delete schema-* tags so as not to confuse auto
run: |
git tag -l "schema-*" | xargs git tag -d
working-directory: dandischema
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dandischema
run: python -m pip install .
working-directory: dandischema
- name: Get schema version
run: |
SCHEMA_VERSION="$(python -c 'from dandischema.consts import DANDI_SCHEMA_VERSION; print(DANDI_SCHEMA_VERSION)')"
if ! echo "$SCHEMA_VERSION" | grep -qP '^\d+\.\d+\.\d+$'
then printf "[ERROR] Invalid schema version: '%s'\n" "$SCHEMA_VERSION"
exit 1
fi
echo "SCHEMA_VERSION=$SCHEMA_VERSION" >> "$GITHUB_ENV"
- name: Checkout dandi/schema
uses: actions/checkout@v4
with:
repository: dandi/schema
path: schema
token: ${{ secrets.DANDI_GITHUB_TOKEN }}
- name: Test for unversioned changes
run: |
dirs="$(echo releases/*)"
echo "Following directories will be checked for differences: $dirs"
python ../dandischema/tools/pubschemata.py releases
git status
git add -A releases
if ! git diff --cached --exit-code $dirs
then echo "[ERROR] Existing schema files modified instead of creating a new version"
exit 1
fi
working-directory: schema
- name: Install build & twine
run: python -m pip install build twine
- name: Download auto
run: |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/tags/$AUTO_VERSION | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
wget -O- "$auto_download_url" | gunzip > ~/auto
chmod a+x ~/auto
- name: Create release
run: |
~/auto shipit -vv
python -m build
twine upload dist/*
env:
GH_TOKEN: ${{ secrets.DANDI_GITHUB_TOKEN }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
working-directory: dandischema
- name: Commit schema changes and create new tag
run: |
LIBRARY_VERSION="$(git -C ../dandischema describe --tags --exact-match)"
git config --global user.email "[email protected]"
git config --global user.name "DANDI Bot"
git add releases
if ! git diff --quiet --cached
then git commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
git push
git -C ../dandischema tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" schema-$SCHEMA_VERSION
git -C ../dandischema push --tags
else echo "No changes to commit"
fi
working-directory: schema
# vim:set sts=2: