forked from ckan/ckan-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (99 loc) · 3.47 KB
/
release-tag-based.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
name: Release - Tag Based
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type (patch/minor/major)'
required: true
default: 'patch'
appName:
description: 'Application Name (data/sample)'
required: true
default: 'data'
branches:
- master
- release/*
jobs:
# sanity-check:
# runs-on: ubuntu-latest
# steps:
# - name: Check branch for patch release
# if: ${{ github.event.inputs.releaseType == 'patch' }}
# run: |
# BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')
# if [[ $BRANCH_NAME == release* ]]; then
# echo "Valid branch for patch release."
# else
# echo "::error::Patch releases are only allowed on branches prefixed with 'release'."
# exit 1
# fi
sanity-check:
runs-on: ubuntu-latest
steps:
- name: Check branch for patch release
if: ${{ github.event.inputs.releaseType == 'patch' }}
run: |
echo "Valid branch for patch release."
build-docker-image:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ vars.USERNAME }}
password: ${{ secrets.TOKEN }}
- name: Build Docker image with 'latest' tag
uses: docker/build-push-action@v2
with:
context: ./ckan
file: ./ckan/Dockerfile
push: true
tags: ghcr.io/auscope/auscope-ckan:latest
prepare-release:
needs: build-docker-image
runs-on: ubuntu-latest
outputs:
new-version: ${{ steps.bump_version.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install bump2version
run: pip install bump2version
- name: Set up Git identity
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
- name: Bump version
id: bump_version
run: |
bump2version ${{ github.event.inputs.releaseType }} --config-file ./ckan/setup.cfg
NEW_VERSION=$(grep 'current_version = ' ./ckan/setup.cfg | sed -r 's/current_version = //')
echo "::set-output name=version::$NEW_VERSION"
- name: Push the tags and changes
run: |
git push origin --tags
git push
retag-and-push-docker-image:
needs: prepare-release
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ vars.USERNAME }}
password: ${{ secrets.TOKEN }}
- name: Pull 'latest' Docker image
run: docker pull ghcr.io/auscope/auscope-ckan:latest
- name: Tag Docker image with new version and AppName
run: docker tag ghcr.io/auscope/auscope-ckan:latest ghcr.io/auscope/auscope-ckan:${{ github.event.inputs.AppName }}-${{ needs.prepare-release.outputs.new-version }}
- name: Push Docker image with new version
run: docker push ghcr.io/auscope/auscope-ckan:${{ github.event.inputs.AppName }}-${{ needs.prepare-release.outputs.new-version }}