-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (122 loc) · 4.8 KB
/
draft-new-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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: "Draft New Release"
on:
workflow_dispatch:
inputs:
version:
description: "The release version"
required: true
jobs:
draft_new_release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create release branch
run: git checkout -b release/${{ github.event.inputs.version }}
- name: Update changelog
uses: thomaseizinger/[email protected]
with:
version: ${{ github.event.inputs.version }}
- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email [email protected]
- name: Bump version in package.json
run: yarn version --new-version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Commit changelog and manifest files
id: make-commit
run: |
git add CHANGELOG.md package.json
git commit --message "Prepare release ${{ github.event.inputs.version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push new branch
run: git push origin release/${{ github.event.inputs.version }}
- name: Create pull request
uses: thomaseizinger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: release/${{ github.event.inputs.version }}
base: main
title: Release version ${{ github.event.inputs.version }}
reviewers: ${{ github.actor }}
body: |
Hi @${{ github.actor }}! 👋
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.
build_and_deploy_stage:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version
run: |
VERSION=${{ github.event.inputs.version }}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set lower case owner name
run: |
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: "${{ github.repository }}"
- name: Set commit sha
run: |
echo "COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Build and push Version
uses: docker/build-push-action@v5
with:
context: .
file: ./.docker/Dockerfile.stage
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-stage:${{ env.RELEASE_VERSION }}-preview, ghcr.io/${{ env.REPO_LC }}-stage:latest, ghcr.io/${{ env.REPO_LC }}-stage:${{ env.COMMIT_SHA }}
- name: "Setup yq"
uses: dcarbone/[email protected]
with:
version: "v4.42.1"
force: true
- name: Initialize mandatory git config
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Bump version in values/stage.yaml
run: yq -i '.deployment.image.tag=strenv(COMMIT_SHA)' ./k8s/values/stage.yaml
- name: Commit k8s values files
id: make-commit
run: |
git add ./k8s/values/stage.yaml
git commit --message "Update stage image to commit ${{ env.COMMIT_SHA }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push changes
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/${{ github.event.inputs.version }}
- name: Delete tag
uses: dev-drprasad/[email protected]
with:
tag_name: stage-deployment
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
run: git tag -fa 'stage-deployment' -m "Update tag to commit ${{ env.COMMIT_SHA }}"
- name: Push tag
run: git push origin tag stage-deployment