Skip to content

Commit da58374

Browse files
authored
Automating the release process (#1087)
1 parent 578fe6e commit da58374

File tree

4 files changed

+83
-15
lines changed

4 files changed

+83
-15
lines changed

.github/workflows/build-test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ jobs:
3737
TARGET_BRANCH: ${{ github.head_ref }}
3838
- name: Output branch name
3939
run: echo ${BRANCH}
40+
- name: Sets build date
41+
run: echo ::set-env name=BUILD_DATE::$(date '+%Y%m%d')
4042
- name: Build Docker images
41-
run: VERSION=${BRANCH} make build
43+
run: VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build
4244
- name: Test Docker images
43-
run: USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} make test
45+
run: USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make test
4446
env:
4547
USE_RANDOM_USER: ${{ matrix.use-random-user }}
4648

.github/workflows/deploy.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@ name: Deploys
22

33
on:
44
push:
5-
tags:
6-
- 4.*
5+
branches:
6+
- trunk
77

88
jobs:
99
deploy:
10+
# Only continue if the commit message has '[deploy]' in it
11+
if: contains(toJson(github.event.commits), '[deploy]') == true
1012
name: Deploy Docker images
1113
runs-on: ubuntu-18.04
1214
steps:
1315
- uses: actions/checkout@v1
1416
- name: Output Docker info
1517
run: docker info
16-
- name: Gets tag as env var if present
17-
run: echo ::set-env name=TAG::${GITHUB_REF#refs/*/}
18-
- name: Output tag if present
19-
run: echo ${TAG}
20-
- name: Build
21-
run: VERSION="${TAG}" make build
18+
- name: Sets build date
19+
run: echo ::set-env name=BUILD_DATE::$(date '+%Y%m%d')
20+
- name: Build base image to get Grid version
21+
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
22+
- name: Get Grid version
23+
# sed used to remove last comma of Selenium version output
24+
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 /')
25+
- name: Display Grid version
26+
run: echo ${GRID_VERSION}
27+
- name: Remove local Docker tag
28+
run: docker rmi selenium/base:local-${BUILD_DATE}
29+
- name: Build images
30+
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
2231
- name: Login Docker Hub
2332
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
2433
env:
@@ -27,9 +36,24 @@ jobs:
2736
- name: Deploy new images
2837
run: VERSION="${TAG}" make release
2938
- name: Tag browser images
30-
run: VERSION="${TAG}" PUSH_IMAGE=true make tag_and_push_browser_images
31-
- name: List Docker images
32-
run: docker images --filter=reference='selenium/*:*' --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}"
39+
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}
44+
- name: Create release notes (release_notes.md)
45+
run: ./generate_release_notes.sh ${LATEST_TAG} origin/automated-release ${GRID_VERSION} ${BUILD_DATE}
46+
- name: Create Release
47+
id: create_release
48+
uses: actions/create-release@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: ${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}
53+
release_name: ${{ env.GRID_VERSION }}-${{ env.BUILD_DATE }}
54+
body_path: release_notes.md
55+
draft: false
56+
prerelease: false
3357
# Enable this part when Selenium 4 is released
3458
# - name: Deploy tag latest
3559
# run: VERSION="${TRAVIS_TAG}" make tag_latest

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
NAME := $(or $(NAME),$(NAME),selenium)
2-
BUILD_DATE := $(shell date '+%Y%m%d')
2+
CURRENT_DATE := $(shell date '+%Y%m%d')
3+
BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE))
34
VERSION := $(or $(VERSION),$(VERSION),4.0.0-alpha-6)
45
TAG_VERSION := $(VERSION)-$(BUILD_DATE)
56
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
67
AUTHORS := $(or $(AUTHORS),$(AUTHORS),SeleniumHQ)
7-
PLATFORM := $(shell uname -s)
88
PUSH_IMAGE := $(or $(PUSH_IMAGE),$(PUSH_IMAGE),false)
99
BUILD_ARGS := $(BUILD_ARGS)
1010
MAJOR := $(word 1,$(subst ., ,$(TAG_VERSION)))

generate_release_notes.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
LATEST_TAG=$1
4+
HEAD_BRANCH=$2
5+
GRID_VERSION=$3
6+
BUILD_DATE=$4
7+
8+
TAG_VERSION=${GRID_VERSION}-${BUILD_DATE}
9+
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+
15+
echo "" >> release_notes.md
16+
echo "### Changelog" > release_notes.md
17+
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
18+
19+
CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $3}')
20+
CHROMEDRIVER_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} chromedriver --version | awk '{print $2}')
21+
FIREFOX_VERSION=$(docker run --rm selenium/node-firefox:${TAG_VERSION} firefox --version | awk '{print $3}')
22+
GECKODRIVER_VERSION=$(docker run --rm selenium/node-firefox:${TAG_VERSION} geckodriver --version | awk 'NR==1{print $2}')
23+
OPERA_VERSION=$(docker run --rm selenium/node-opera:${TAG_VERSION} opera --version)
24+
OPERADRIVER_VERSION=$(docker run --rm selenium/node-opera:${TAG_VERSION} operadriver --version | awk 'NR==1{print $2}')
25+
26+
27+
echo "" >> release_notes.md
28+
echo "### Released versions" >> release_notes.md
29+
echo "* Selenium: ${GRID_VERSION}" >> release_notes.md
30+
echo "* Chrome: ${CHROME_VERSION}" >> release_notes.md
31+
echo "* ChromeDriver: ${CHROMEDRIVER_VERSION}" >> release_notes.md
32+
echo "* Firefox: ${FIREFOX_VERSION}" >> release_notes.md
33+
echo "* GeckoDriver: ${GECKODRIVER_VERSION}" >> release_notes.md
34+
echo "* Opera: ${OPERA_VERSION}" >> release_notes.md
35+
echo "* OperaDriver: ${OPERADRIVER_VERSION}" >> release_notes.md
36+
37+
echo "" >> release_notes.md
38+
echo "### Published Docker images" >> release_notes.md
39+
echo '```' >> release_notes.md
40+
docker images --filter=reference='selenium/*:*' --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}" >> release_notes.md
41+
echo '```' >> release_notes.md
42+

0 commit comments

Comments
 (0)