forked from apache/lucenenet
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (127 loc) · 4.7 KB
/
Copy pathLucene-Net-Website.yml
File metadata and controls
145 lines (127 loc) · 4.7 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: 'Lucene.Net.Website'
# This will:
# checkout this repo
# get current or latest tag to parse a version for use in the website
# Build the website
# Checkout the website repo
# Create a branch
# Commit/Push to the branch
# Create a PR
on:
workflow_dispatch:
push:
tags:
- Website_*
#branches:
#- master
paths:
- 'websites/site/**/*'
env:
# If a tag is specified, the tag will be in the format: Website_4_8_0_beta00013 which
# will be parsed to create the version number used in the docs like 4.8.0-beta00013
RELEASE_VERSION: "(no tag)"
SITE_REPO: "${{ github.repository }}-site"
GIT_MAIN_REPO: "${{ github.workspace }}\\main-repo\\.git"
jobs:
build:
runs-on: windows-latest
steps:
# Checkout the main repo with all history so we get all tags
- name: Checkout Lucene.Net source
uses: actions/checkout@v5
with:
path: main-repo
fetch-depth: 0
- name: Set version from tag
run: |
$ref = $Env:GITHUB_REF
if ($ref.StartsWith("refs/tags/")) {
$tag = $ref.Substring(10)
echo "extracted tag name from refs/tags as $tag"
}
else {
echo "Get the latest Lucene.Net_ tag"
$tag = & git --git-dir "$Env:GIT_MAIN_REPO" tag --list --sort=-version:refname 'Lucene.Net_[0-9]_[0-9]_[0-9]*' | select -first 1
}
if ($tag -eq $null) {
echo "::error::Could not determine current version tag"
exit 1
}
$parts = $tag.Split("_")
$version = '';
For ($i=1; $i -le $parts.Length; $i++) {
$version += $parts[$i]
if ($i -eq ($parts.Length - 2)) {
$version += "-"
}
elseif ($i -lt ($parts.Length - 1)) {
$version += "."
}
}
if ($version -ne '') {
# the tag parsed to the correct version format, write the environment var
echo "parsed version is $version"
echo ("RELEASE_VERSION=" + $version) >> $env:GITHUB_ENV
}
else {
echo "::error::Could not parse current version tag"
exit 1
}
shell: powershell
- name: Verify environment variables
run: |
echo "RELEASE_VERSION=$Env:RELEASE_VERSION"
shell: powershell
- name: Build website
run: ./main-repo/websites/site/site.ps1 -Clean
shell: powershell
- name: Upload website as build artifact
uses: actions/upload-artifact@v5
if: ${{always()}}
with:
name: 'website'
path: '${{github.workspace}}/main-repo/websites/site/_site'
- name: Checkout Lucene.Net website
uses: actions/checkout@v5
with:
repository: ${{ env.SITE_REPO }}
ref: asf-site
path: website-repo
- name: Copy website files
run: Get-ChildItem -Path "$Env:GITHUB_WORKSPACE\main-repo\websites\site\_site" | Copy-Item -Destination "$Env:GITHUB_WORKSPACE\website-repo" -Recurse -Force
shell: powershell
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.LUCENE_NET_WEBSITE_BUILD }}
path: website-repo
commit-message: New website version built
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: task/website-build-${{ github.sha }}
delete-branch: true
title: 'New website build ${{ github.sha }}'
body: |
New website build on rev/tag ${{ github.sha }}
For release version ${{ env.RELEASE_VERSION }}
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"