Skip to content

Commit d1a1d1e

Browse files
committed
release: chore - add new release workflow using magefiles
Signed-off-by: Ian Cardoso <ian.cardoso@zup.com.br>
1 parent 438a976 commit d1a1d1e

File tree

8 files changed

+285
-81
lines changed

8 files changed

+285
-81
lines changed

.github/workflows/new-release.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ jobs:
8585
HORUSEC_REPOSITORY_NAME: ${{ github.event.repository.name }}
8686

8787
- name: Checkout release candidate branch
88-
run: cd deployments/mage/ && mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.releaseVersion }}
88+
run: cd deployments/mage/ && mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.nextReleaseBranchName }}
8989

9090
- name: Update versions on package.json
91-
run: cd deployments/mage/ && mage -v updatePackageJson ${{ steps.updated-version.outputs.strippedVersion }}
91+
run: cd deployments/mage/ && mage -v updatePackageJson ${{ steps.updated-version.outputs.nextReleaseVersionStripped }}
9292

9393
- name: Update versions on rest of the project
94-
run: cd deployments/mage/ && mage -v updateHorusecVersionInProject ${{ steps.updated-version.outputs.actualVersion }} ${{ steps.updated-version.outputs.releaseVersion }} |
94+
run: cd deployments/mage/ && mage -v updateHorusecVersionInProject ${{ steps.updated-version.outputs.actualReleaseVersion }} ${{ steps.updated-version.outputs.nextReleaseVersion }} |
9595

9696
- name: Commit changes
9797
uses: EndBug/add-and-commit@v7.4.0
@@ -103,7 +103,7 @@ jobs:
103103
committer_name: Horusec
104104
committer_email: horusec@zup.com.br
105105
- name: Create local tag
106-
run: cd deployments/mage/ && mage -v createLocalTag ${{ steps.updated-version.outputs.releaseVersion }}
106+
run: cd deployments/mage/ && mage -v createLocalTag ${{ steps.updated-version.outputs.nextReleaseVersion }}
107107

108108
- name: Run GoReleaser
109109
uses: goreleaser/goreleaser-action@v2
@@ -115,16 +115,16 @@ jobs:
115115
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
116116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117117
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
118-
GORELEASER_CURRENT_TAG: ${{ steps.updated-version.outputs.releaseVersion }}
118+
GORELEASER_CURRENT_TAG: ${{ steps.updated-version.outputs.nextReleaseVersion }}
119119

120120
- name: "Docker meta"
121121
uses: docker/metadata-action@v3
122122
id: meta
123123
env:
124-
RELEASE_VERSION: ${{ steps.updated-version.outputs.version }}
124+
RELEASE_VERSION: ${{ steps.updated-version.outputs.nextReleaseVersion }}
125125
with:
126126
images: |
127-
horuszup/horusec-manager
127+
osodracnai/horusec-manager
128128
tags: |
129129
type=semver,prefix=v,pattern={{version}},value=${{ env.RELEASE_VERSION }}
130130
type=semver,prefix=v,pattern={{major}}.{{minor}},value=${{ env.RELEASE_VERSION }}
@@ -140,7 +140,7 @@ jobs:
140140
labels: ${{ steps.meta.outputs.labels }}
141141
- name: Sign image
142142
run: |
143-
cosign sign -key $COSIGN_KEY_LOCATION horuszup/horusec-manager:latest
143+
cosign sign -key $COSIGN_KEY_LOCATION osodracnai/horusec-manager:latest
144144
env:
145145
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
146146

@@ -153,19 +153,15 @@ jobs:
153153
id: cherry-pick
154154
run: |
155155
mage CherryPick
156-
- name: Push updates
157-
run: cd deployments/mage/ && mage -v gitPushAll
158-
159-
160156
# This step utilizes an action to create a pull request with the branch that was cherry picked on the last step
161157
# into the main branch. As the last commit, this also needs to run only when the release workflow is started from a
162158
# branch that isn't the main branch. Others workflows should be skipped cause of the skip ci in the pull request title.
163159
- name: Create Pull Request
164160
if: github.ref != 'refs/heads/main'
165161
uses: repo-sync/pull-request@v2
166162
with:
167-
source_branch: "${{ steps.cherry-pick.outputs.branchName }}"
163+
source_branch: "${{ steps.cherry-pick.outputs.cherryPickBranchName }}"
168164
destination_branch: "main"
169165
pr_title: "versioning:release - [skip ci] automatic pull request updating versioning files"
170-
pr_body: "This is a automatic pull request that contains changes to files that need to be updated with the new release version. Where the commit ${{ steps.cherry-pick.outputs.commitSha }} was cherry picked from the release branch, which already contains all the necessary changes."
166+
pr_body: "This is a automatic pull request that contains changes to files that need to be updated with the new release version. Where the commit ${{ steps.cherry-pick.outputs.commitShaToPick }} was cherry picked from the release branch, which already contains all the necessary changes."
171167
github_token: ${{ secrets.HORUSEC_PUSH_TOKEN }}

.github/workflows/release-beta.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Copyright 2021 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: release-beta
16+
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
releaseType:
21+
description: 'Release type: M (Major); m (Minor); p (Path)'
22+
required: true
23+
24+
permissions: read-all
25+
jobs:
26+
beta:
27+
permissions:
28+
contents: write
29+
packages: write
30+
env:
31+
COSIGN_KEY_LOCATION: /tmp/cosign.key
32+
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Set up nodejs
37+
uses: actions/setup-node@v2
38+
with:
39+
node-version: 12
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Set up Go
46+
uses: actions/setup-go@v2
47+
with:
48+
go-version: 1.17
49+
50+
- name: Docker Login
51+
uses: docker/login-action@v1
52+
with:
53+
username: ${{ secrets.DOCKERHUB_USERNAME }}
54+
password: ${{ secrets.DOCKERHUB_TOKEN }}
55+
- name: Cosign Installer
56+
uses: sigstore/cosign-installer@main
57+
with:
58+
cosign-release: 'v1.2.0'
59+
60+
- name: Install Mage
61+
run: |
62+
cd deployments/mage/ && go run mage.go -compile ../../mage
63+
64+
- name: Git config
65+
run: |
66+
./mage -v defaultGitConfig
67+
68+
- name: Import GPG key
69+
uses: crazy-max/ghaction-import-gpg@v4
70+
with:
71+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
72+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
73+
git_user_signingkey: true
74+
git_commit_gpgsign: true
75+
76+
- name: Install cosign private key
77+
run: |
78+
./mage -v writeCosignKeyToFile
79+
env:
80+
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
81+
82+
- name: Version increment
83+
id: updated-version
84+
run: |
85+
./mage -v upVersions ${{ github.event.inputs.releaseType }}
86+
env:
87+
HORUSEC_REPOSITORY_ORG: ${{ github.repository_owner }}
88+
HORUSEC_REPOSITORY_NAME: ${{ github.event.repository.name }}
89+
90+
- name: Checkout release candidate branch
91+
run: |
92+
./mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.nextReleaseBranchName }}
93+
94+
- name: Create local tag
95+
run: |
96+
./mage -v createLocalTag ${{ steps.updated-version.outputs.nextBetaVersion }}
97+
98+
- name: Run GoReleaser
99+
uses: goreleaser/goreleaser-action@v2
100+
with:
101+
distribution: goreleaser
102+
version: latest
103+
args: release --rm-dist --skip-publish
104+
env:
105+
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
108+
GORELEASER_CURRENT_TAG: ${{ steps.updated-version.outputs.nextBetaVersion }}
109+
110+
- name: Push go projects to dockerhub
111+
run: |
112+
./mage -v dockerPushPlatformGoProjects ${{ steps.updated-version.outputs.nextBetaVersion }}
113+
114+
- name: Sign go projects in dockerhub
115+
env:
116+
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
117+
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
118+
run: |
119+
./mage -v dockerSignPlatformGoProjects ${{ steps.updated-version.outputs.nextBetaVersion }}
120+
121+
- name: "Docker meta"
122+
uses: docker/metadata-action@v3
123+
id: meta
124+
env:
125+
RELEASE_VERSION: ${{ steps.updated-version.outputs.nextBetaVersion }}
126+
with:
127+
images: |
128+
osodracnai/horusec-manager
129+
tags: |
130+
type=semver,prefix=v,pattern={{version}},value=${{ env.RELEASE_VERSION }}
131+
type=semver,prefix=v,pattern={{major}}.{{minor}},value=${{ env.RELEASE_VERSION }}
132+
type=semver,prefix=v,pattern={{major}},value=${{ env.RELEASE_VERSION }}
133+
134+
- name: "Build and push manager"
135+
uses: docker/build-push-action@v2
136+
with:
137+
push: true
138+
context: ./manager
139+
file: ./manager/deployments/dockerfiles/Dockerfile
140+
tags: ${{ steps.meta.outputs.tags }}
141+
labels: ${{ steps.meta.outputs.labels }}
142+
143+
- name: Sign image
144+
run: |
145+
cosign sign -key $COSIGN_KEY_LOCATION osodracnai/horusec-manager:${{ steps.updated-version.outputs.nextBetaVersion }}
146+
env:
147+
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
148+
149+
- name: Push updates
150+
run: |
151+
./mage -v gitPushAll

.github/workflows/release-rc.yml

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ jobs:
5858
cosign-release: 'v1.2.0'
5959

6060
- name: Install Mage
61-
run: go install github.com/magefile/mage@07afc7d24f4d6d6442305d49552f04fbda5ccb3e
61+
run: |
62+
cd deployments/mage/ && go run mage.go -compile ../../mage
6263
6364
- name: Git config
64-
run: cd deployments/mage/ && mage -v defaultGitConfig
65+
run: |
66+
./mage -v defaultGitConfig
6567
6668
- name: Import GPG key
6769
uses: crazy-max/ghaction-import-gpg@v4
@@ -72,59 +74,58 @@ jobs:
7274
git_commit_gpgsign: true
7375

7476
- name: Install cosign private key
75-
run: cd deployments/mage/ && mage -v writeCosignKeyToFile
77+
run: |
78+
./mage -v writeCosignKeyToFile
7679
env:
7780
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
7881

7982
- name: Version increment
8083
id: updated-version
8184
run: |
82-
cd deployments/mage/ && mage -v upVersions ${{ github.event.inputs.releaseType }}
85+
./mage -v upVersions ${{ github.event.inputs.releaseType }}
8386
env:
8487
HORUSEC_REPOSITORY_ORG: ${{ github.repository_owner }}
8588
HORUSEC_REPOSITORY_NAME: ${{ github.event.repository.name }}
8689

8790
- name: Checkout release candidate branch
88-
run: cd deployments/mage/ && mage -v checkoutRcBranch ${{ steps.updated-version.outputs.rcVersion }}
89-
90-
# - name: Update versions on package.json
91-
# run: cd deployments/mage/ && mage -v updatePackageJson ${{ steps.updated-version.outputs.strippedVersion }}
92-
93-
# - name: Update versions on rest of the project
94-
# run: cd deployments/mage/ && mage -v updateHorusecVersionInProject ${{ steps.updated-version.outputs.actualVersion }} ${{ steps.updated-version.outputs.rcVersion }} |
95-
96-
# - name: Commit changes
97-
# uses: EndBug/add-and-commit@v7.4.0
98-
# with:
99-
# push: false
100-
# signoff: true
101-
# author_name: Horusec
102-
# author_email: horusec@zup.com.br
103-
# committer_name: Horusec
104-
# committer_email: horusec@zup.com.br
91+
run: |
92+
./mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.nextReleaseBranchName }}
93+
10594
- name: Create local tag
106-
run: cd deployments/mage/ && mage -v createLocalTag ${{ steps.updated-version.outputs.rcVersion }}
95+
run: |
96+
./mage -v createLocalTag ${{ steps.updated-version.outputs.nextRcVersion }}
10797
10898
- name: Run GoReleaser
10999
uses: goreleaser/goreleaser-action@v2
110100
with:
111101
distribution: goreleaser
112102
version: latest
113-
args: release --rm-dist
103+
args: release --rm-dist --skip-publish
114104
env:
115105
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
116106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117107
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
118-
GORELEASER_CURRENT_TAG: ${{ steps.updated-version.outputs.rcVersion }}
108+
GORELEASER_CURRENT_TAG: ${{ steps.updated-version.outputs.nextRcVersion }}
109+
110+
- name: Push go projects to dockerhub
111+
run: |
112+
./mage -v dockerPushPlatformGoProjects ${{ steps.updated-version.outputs.nextRcVersion }}
113+
114+
- name: Sign go projects in dockerhub
115+
env:
116+
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
117+
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
118+
run: |
119+
./mage -v dockerSignPlatformGoProjects ${{ steps.updated-version.outputs.nextRcVersion }}
119120
120121
- name: "Docker meta"
121122
uses: docker/metadata-action@v3
122123
id: meta
123124
env:
124-
RELEASE_VERSION: ${{ steps.updated-version.outputs.version }}
125+
RELEASE_VERSION: ${{ steps.updated-version.outputs.nextRcVersion }}
125126
with:
126127
images: |
127-
horuszup/horusec-manager
128+
osodracnai/horusec-manager
128129
tags: |
129130
type=semver,prefix=v,pattern={{version}},value=${{ env.RELEASE_VERSION }}
130131
type=semver,prefix=v,pattern={{major}}.{{minor}},value=${{ env.RELEASE_VERSION }}
@@ -138,34 +139,13 @@ jobs:
138139
file: ./manager/deployments/dockerfiles/Dockerfile
139140
tags: ${{ steps.meta.outputs.tags }}
140141
labels: ${{ steps.meta.outputs.labels }}
142+
141143
- name: Sign image
142144
run: |
143-
cosign sign -key $COSIGN_KEY_LOCATION horuszup/horusec-manager:latest
145+
cosign sign -key $COSIGN_KEY_LOCATION osodracnai/horusec-manager:${{ steps.updated-version.outputs.nextRcVersion }}
144146
env:
145147
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
146148

147-
# # This step gets the sha of last commit made, witch is the updating versioning files commit, after that creates a
148-
# # branch from the origin main and cherry pick this commit on it. This process need to occur only when the release
149-
# # workflow is started from a branch that isn't the main branch, for example a release branch.
150-
# # When the workflow it's triggered to run on main, the commit it's going to be made directly to the main branch.
151-
# - name: Cherry pick
152-
# if: github.ref != 'refs/heads/main'
153-
# id: cherry-pick
154-
# run: |
155-
# mage CherryPick
156-
# - name: Push updates
157-
# run: cd deployments/mage/ && mage -v gitPushAll
158-
#
159-
#
160-
# # This step utilizes an action to create a pull request with the branch that was cherry picked on the last step
161-
# # into the main branch. As the last commit, this also needs to run only when the release workflow is started from a
162-
# # branch that isn't the main branch. Others workflows should be skipped cause of the skip ci in the pull request title.
163-
# - name: Create Pull Request
164-
# if: github.ref != 'refs/heads/main'
165-
# uses: repo-sync/pull-request@v2
166-
# with:
167-
# source_branch: "${{ steps.cherry-pick.outputs.branchName }}"
168-
# destination_branch: "main"
169-
# pr_title: "versioning:release - [skip ci] automatic pull request updating versioning files"
170-
# pr_body: "This is a automatic pull request that contains changes to files that need to be updated with the new release version. Where the commit ${{ steps.cherry-pick.outputs.commitSha }} was cherry picked from the release branch, which already contains all the necessary changes."
171-
# github_token: ${{ secrets.HORUSEC_PUSH_TOKEN }}
149+
- name: Push updates
150+
run: |
151+
./mage -v gitPushAll

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ vendor
2020
**/e2e/cypress/src/screenshots/**
2121
**/e2e/cypress/src/videos/**
2222
dist/
23+
mage

0 commit comments

Comments
 (0)