-
Notifications
You must be signed in to change notification settings - Fork 19
132 lines (102 loc) · 3.38 KB
/
create-release.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: "Create release"
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l -e -o pipefail {0}
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: |
# Avoid git exiting when Actions runs
git config --global --add safe.directory "$PWD"
git fetch --tags --force
- name: "Build Package"
uses: wtsi-npg/[email protected]
with:
build-script:
./.github/workflows/build.sh
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: baton-release-tarball
path: "baton-*.tar.gz*"
release:
runs-on: ubuntu-latest
needs: "build"
defaults:
run:
shell: bash -l -e -o pipefail {0}
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: |
# Avoid git exiting when Actions runs
git config --global --add safe.directory "$PWD"
git fetch --tags --force
- name: "Get release variables"
run: |
echo 'RELEASE_VERSION='$(git describe --always --tags) >> $GITHUB_ENV
echo 'MASTER_SHA='$(git rev-parse origin/master) >> $GITHUB_ENV
- name: "Download artifact"
uses: actions/download-artifact@v4
with:
name: baton-release-tarball
- name: "Create Release"
uses: ncipollo/[email protected]
with:
name: ${{ env.RELEASE_VERSION }}
prerelease: ${{ !(github.sha == env.MASTER_SHA) }}
artifacts: "baton-*.tar.gz*"
removeArtifacts: true
artifactErrorsFailBuild: true
generateReleaseNotes: true
outputs:
isRelease: ${{ github.sha == env.MASTER_SHA }}
deploy:
runs-on: ubuntu-latest
needs: [build, release]
# Workaround for https://github.com/actions/runner/issues/1483
# Actions coerces boolean to string
if: needs.release.outputs.isRelease == 'true'
steps:
- name: "Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: |
# Avoid git exiting when Actions runs
git config --global --add safe.directory "$PWD"
git fetch --tags --force
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
with:
install: true
- name: "Login to Docker registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build and push Docker image"
run: |
cd release
make GITHUB_ACTIONS=${GITHUB_ACTIONS} GITHUB_REPOSITORY_OWNER=${{ github.repository_owner }}
docker image prune --force
docker images
make push GITHUB_ACTIONS=${GITHUB_ACTIONS} GITHUB_REPOSITORY_OWNER=${{ github.repository_owner }}