-
Notifications
You must be signed in to change notification settings - Fork 2k
146 lines (129 loc) · 5.28 KB
/
release.yml
File metadata and controls
146 lines (129 loc) · 5.28 KB
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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
env:
VERSION: '0.0.0'
permissions:
contents: write
id-token: write
steps:
# =================================================================
# 1. SETUP
# =================================================================
- name: Checkout code
uses: actions/checkout@v6
- name: Initialize VERSION
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
else
echo "VERSION=0.0.0" >> $GITHUB_ENV
fi
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
server-id: central
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Node.js and pnpm
uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
uses: pnpm/action-setup@v5
with:
version: 9
# =================================================================
# 2. BUILD & TEST
# =================================================================
- name: Build and test all packages
run: ./scripts/build-all.sh ${{ env.VERSION }}
# =================================================================
# 3. DEPLOY (only on tag push)
# =================================================================
- name: '[Java] Deploy to Maven Central'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: mvn -B -pl opendataloader-pdf-core deploy -P release
working-directory: ./java
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: '[Python] Publish to PyPI'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./python/opendataloader-pdf/dist
- name: '[Node.js] Publish to npm'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: pnpm publish --no-git-checks
working-directory: ./node/opendataloader-pdf
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# =================================================================
# 4. GITHUB RELEASE (only on tag push)
# =================================================================
- name: Package CLI as ZIP
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cd java/opendataloader-pdf-cli/target
mkdir -p release
cp "opendataloader-pdf-cli-${{ env.VERSION }}.jar" release/
cp ../../../README.md release/
cp ../../../LICENSE release/
cp ../../../NOTICE release/
cp -r ../../../THIRD_PARTY release/
cd release
zip -r "../opendataloader-pdf-cli-${{ env.VERSION }}.zip" .
cd ../..
- name: Create GitHub Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
generate_release_notes: true
files: |
java/opendataloader-pdf-cli/target/opendataloader-pdf-cli-${{ env.VERSION }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# =================================================================
# 5. SYNC DOCS TO HOMEPAGE (only on tag push)
# =================================================================
- name: Generate reference docs
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
mkdir -p content/docs/reference
node scripts/generate-options.mjs
node scripts/generate-schema.mjs
- name: Push reference docs to homepage
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# Pinned to v1.7.3 for security - verify before updating
uses: cpina/github-action-push-to-another-repository@55306faa4ed53b815ae49e564af8cfb359d32ae2 # v1.7.3
with:
source-directory: 'content/docs/reference'
destination-github-username: 'opendataloader-project'
destination-repository-name: 'opendataloader.org'
target-directory: 'apps/v1/content/docs/reference'
target-branch: main
env:
API_TOKEN_GITHUB: ${{ secrets.HOMEPAGE_SYNC_TOKEN }}