Skip to content

Commit 768cfe7

Browse files
authored
Enable prereleases and replacing release text across files (#1101)
1 parent 6c3d810 commit 768cfe7

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

.github/workflows/deploy.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,58 @@ jobs:
1212
name: Deploy Docker images
1313
runs-on: ubuntu-18.04
1414
steps:
15-
- uses: actions/checkout@v1
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
with:
18+
persist-credentials: false
19+
fetch-depth: 0
1620
- name: Output Docker info
1721
run: docker info
1822
- name: Sets build date
1923
run: echo ::set-env name=BUILD_DATE::$(date '+%Y%m%d')
24+
- name: Sets prerelease to false by default
25+
run: echo ::set-env name=PRERELEASE::false
2026
- name: Build base image to get Grid version
2127
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
2228
- name: Get Grid version
2329
# sed used to remove last comma of Selenium version output
2430
run: echo ::set-env name=GRID_VERSION::$(docker run --rm selenium/base:local-${BUILD_DATE} java -jar /opt/selenium/selenium-server.jar hub --version | awk '{print $3}' | sed 's/\(.*\),/\1 /')
31+
- name: Is it a prerelease?
32+
run: echo ::set-env name=GRID_VERSION::${GRID_VERSION}-prerelease && echo ::set-env name=PRERELEASE::true
33+
if: contains(toJson(github.event.commits), '[prerelease]') == true
2534
- name: Display Grid version
2635
run: echo ${GRID_VERSION}
2736
- name: Remove local Docker tag
2837
run: docker rmi selenium/base:local-${BUILD_DATE}
38+
- name: Sets env var for the next tag
39+
run: echo ::set-env name=NEXT_TAG::"${GRID_VERSION}"-${BUILD_DATE}
40+
- name: Get latest tag
41+
run: echo ::set-env name=LATEST_TAG::$(git tag | tail -1)
42+
- name: Display latest tag
43+
run: echo ${LATEST_TAG}
44+
- name: Update tag in docs and files
45+
run: ./update_tag_in_docs_and_files.sh ${LATEST_TAG} ${NEXT_TAG}
2946
- name: Build images
3047
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
48+
- name: Commit files
49+
run: |
50+
git config --local user.email "[email protected]"
51+
git config --local user.name "GitHub Action"
52+
git commit -m "Update tag in docs and files" -a
53+
- name: Push changes
54+
uses: ad-m/github-push-action@master
55+
with:
56+
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
branch: trunk
3158
- name: Login Docker Hub
3259
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
3360
env:
3461
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
3562
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
3663
- name: Deploy new images
37-
run: VERSION="${TAG}" make release
64+
run: make release
3865
- name: Tag browser images
3966
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true make tag_and_push_browser_images
40-
- name: Get latest tag
41-
run: echo ::set-env name=LATEST_TAG::$(git tag | tail -1)
42-
- name: Display latest tag
43-
run: echo ${LATEST_TAG}
4467
- name: Create release notes (release_notes.md)
4568
run: ./generate_release_notes.sh ${LATEST_TAG} origin/trunk ${GRID_VERSION} ${BUILD_DATE}
4669
- name: Create Release
@@ -53,7 +76,8 @@ jobs:
5376
release_name: ${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}
5477
body_path: release_notes.md
5578
draft: false
56-
prerelease: false
79+
prerelease: ${{ env.PRERELEASE }}
80+
5781
# Enable this part when Selenium 4 is released
5882
# - name: Deploy tag latest
5983
# run: VERSION="${TRAVIS_TAG}" make tag_latest

generate_release_notes.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ BUILD_DATE=$4
77

88
TAG_VERSION=${GRID_VERSION}-${BUILD_DATE}
99

10-
# Get all tags, branches, and history
11-
#git fetch --depth=1 origin +refs/tags/*:refs/tags/* 1>&2
12-
#git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 1>&2
13-
#git fetch --prune --unshallow 1>&2
14-
1510
echo "" >> release_notes.md
1611
echo "### Changelog" > release_notes.md
1712
git --no-pager log "${LATEST_TAG}...${HEAD_BRANCH}" --pretty=format:"* [\`%h\`](http://github.com/seleniumhq/docker-selenium/commit/%H) - %s :: %an" --reverse >> release_notes.md

update_tag_in_docs_and_files.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
LATEST_TAG=$1
4+
NEXT_TAG=$2
5+
6+
echo -e "\033[0;32m Updating tag displayed in docs and files...\033[0m"
7+
echo -e "\033[0;32m LATEST_TAG -> ${LATEST_TAG}\033[0m"
8+
echo -e "\033[0;32m NEXT_TAG -> ${NEXT_TAG}\033[0m"
9+
10+
# If you want to test this locally and you are using macOS, do `brew install gnu-sed` and change `sed` for `gsed`.
11+
find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/${LATEST_TAG}/${NEXT_TAG}/g"
12+
13+
git diff | cat
14+
15+
echo -e "\033[0;32m Text updated...\033[0m"

0 commit comments

Comments
 (0)