-
Notifications
You must be signed in to change notification settings - Fork 3
191 lines (184 loc) · 6.64 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# based on: https://github.com/SaltyQuetzals/TAMU-Grade-Distribution-CSVs/blob/master/.github/workflows/release.yml
on:
push:
branches:
- master
name: Create Release
jobs:
prep:
name: Create Release
runs-on: ubuntu-latest
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
release_tag: ${{ steps.timestamp.outputs.timestamptag }}
npmtag: ${{ steps.timestamp.outputs.npmtag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Get current date and timestamp
id: timestamp
run: |
echo "timestamp=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
echo "timestamptag=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_OUTPUT
echo "npmtag=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ steps.timestamp.outputs.timestamptag }}"
draft: false
prerelease: false
build_test_1:
name: Make test bundle (Summer 2020)
runs-on: ubuntu-latest
needs: [ prep ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Make test bundle (Summer 2020)
id: maketestbundle202002
run: |
pip install -r bundler/requirements.txt
mkdir -p exports/
VAR=$PWD/exports/publicdata-testbundle-summer2020.tar.gz
python bundler/bundle.py -o "$VAR" --testbundle "*2020-02*.csv"
echo "tarloc=$VAR" >> $GITHUB_OUTPUT
echo "tarname=$(basename $VAR)" >> $GITHUB_OUTPUT
- name: Upload Release Asset (Test Bundle Summer 2020)
id: upload-release-asset-testbundle202002
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prep.outputs.release_tag }}
ASSET_PATH: "${{ steps.maketestbundle202002.outputs.tarloc }}"
REPO_NAME: ${{ github.repository }}
run: gh release upload "$RELEASE_TAG" "$ASSET_PATH" -R "$REPO_NAME"
build_test_2:
name: Make test bundle (2021 year)
runs-on: ubuntu-latest
needs: [ prep ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Make test bundle (2021 year)
id: maketestbundle2021
run: |
pip install -r bundler/requirements.txt
mkdir -p exports/
VAR=$PWD/exports/publicdata-testbundle-year2021.tar.gz
python bundler/bundle.py -o "$VAR" --testbundle "*2021*.csv"
echo "tarloc=$VAR" >> $GITHUB_OUTPUT
echo "tarname=$(basename $VAR)" >> $GITHUB_OUTPUT
- name: Upload Release Asset (Test Bundle 2021 Year)
id: upload-release-asset-testbundle2021
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prep.outputs.release_tag }}
ASSET_PATH: "${{ steps.maketestbundle2021.outputs.tarloc }}"
REPO_NAME: ${{ github.repository }}
run: gh release upload "$RELEASE_TAG" "$ASSET_PATH" -R "$REPO_NAME"
build_full:
name: Make full bundle + Publish
runs-on: ubuntu-latest
needs: [ prep ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Make bundle
id: makebundle
run: |
pip install -r bundler/requirements.txt
mkdir -p exports/
VAR=$PWD/exports/publicdata-bundle.tar.gz
ALT=$PWD/npm/bundle
VAR_TEMP=$(dirname $VAR)/$(basename $VAR .gz)
python bundler/bundle.py --skiprmtree -o "$VAR"
mv $VAR_TEMP/* $ALT
echo "tarloc=$VAR" >> $GITHUB_OUTPUT
echo "tarname=$(basename $VAR)" >> $GITHUB_OUTPUT
- name: Upload Release Asset
id: upload-release-asset-full
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prep.outputs.release_tag }}
ASSET_PATH: "${{ steps.makebundle.outputs.tarloc }}"
REPO_NAME: ${{ github.repository }}
run: gh release upload "$RELEASE_TAG" "$ASSET_PATH" -R "$REPO_NAME"
# Publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
cd npm
node repackage.js ${{ needs.prep.outputs.npmtag }}
npm publish --access public
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://npm.pkg.github.com'
# Publish to GitHub Packages
- name: Publish to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd npm
node repackage.js ${{ needs.prep.outputs.npmtag }}
npm publish
make_mock_database:
name: Build local copy of database
runs-on: ubuntu-latest
needs: [ prep, build_full ]
defaults:
run:
working-directory: mock-database
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install + Compile
run: |
npm install
npm run build
- name: Download latest public data bundle
run: node build/downloadBundle.js
- name: Build local copy of the database
run: node build/createMockDatabase.js
- name: Compress mock database
id: makemockdatabase
run: |
tar -czf tmp/database.tar.gz -C tmp/firebaseFS/ $(ls tmp/firebaseFS/)
echo "tarloc=tmp/database.tar.gz" >> $GITHUB_OUTPUT
- name: Upload Release Asset (Mock Database)
id: upload-release-asset-mockdb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.prep.outputs.release_tag }}
ASSET_PATH: "${{ steps.makemockdatabase.outputs.tarloc }}"
REPO_NAME: ${{ github.repository }}
run: gh release upload "$RELEASE_TAG" "$ASSET_PATH" -R "$REPO_NAME"