Skip to content

Commit e2ebced

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

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

.github/workflows/new-release.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: New-Release
15+
name: release-new
1616

1717
on:
1818
workflow_dispatch:
@@ -58,10 +58,11 @@ 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: ./mage -v defaultGitConfig
6566

6667
- name: Import GPG key
6768
uses: crazy-max/ghaction-import-gpg@v4
@@ -72,38 +73,23 @@ jobs:
7273
git_commit_gpgsign: true
7374

7475
- name: Install cosign private key
75-
run: cd deployments/mage/ && mage -v writeCosignKeyToFile
76+
run: ./mage -v writeCosignKeyToFile
7677
env:
7778
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
7879

7980
- name: Version increment
8081
id: updated-version
8182
run: |
82-
cd deployments/mage/ && mage -v upVersions ${{ github.event.inputs.releaseType }}
83+
./mage -v upVersions ${{ github.event.inputs.releaseType }}
8384
env:
8485
HORUSEC_REPOSITORY_ORG: ${{ github.repository_owner }}
8586
HORUSEC_REPOSITORY_NAME: ${{ github.event.repository.name }}
8687

8788
- name: Checkout release candidate branch
88-
run: cd deployments/mage/ && mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.nextReleaseBranchName }}
89-
90-
- name: Update versions on package.json
91-
run: cd deployments/mage/ && mage -v updatePackageJson ${{ steps.updated-version.outputs.nextReleaseVersionStripped }}
89+
run: ./mage -v checkoutReleaseBranch ${{ steps.updated-version.outputs.nextReleaseBranchName }}
9290

93-
- name: Update versions on rest of the project
94-
run: cd deployments/mage/ && mage -v updateHorusecVersionInProject ${{ steps.updated-version.outputs.actualReleaseVersion }} ${{ steps.updated-version.outputs.nextReleaseVersion }} |
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
10591
- name: Create local tag
106-
run: cd deployments/mage/ && mage -v createLocalTag ${{ steps.updated-version.outputs.nextReleaseVersion }}
92+
run: ./mage -v createLocalTag ${{ steps.updated-version.outputs.nextReleaseVersion }}
10793

10894
- name: Run GoReleaser
10995
uses: goreleaser/goreleaser-action@v2
@@ -144,6 +130,23 @@ jobs:
144130
env:
145131
COSIGN_PASSWORD: ${{ secrets.COSIGN_PWD }}
146132

133+
- name: Update versions on package.json
134+
run: ./mage -v updatePackageJson ${{ steps.updated-version.outputs.nextReleaseVersionStripped }}
135+
136+
- name: Update versions on rest of the project
137+
run: |
138+
find . -type f -not -path "./.git/*" -not -path "./Makefile" -not -path "./manager/cypress/*" -not -name "*.sum" -not -name "*.mod"|
139+
xargs sed -i "s/${{ steps.updated-version.outputs.actualReleaseVersion }}/${{ steps.updated-version.outputs.nextReleaseVersion }}/g"
140+
141+
- name: Commit changes
142+
uses: EndBug/add-and-commit@v7.4.0
143+
with:
144+
push: false
145+
signoff: true
146+
author_name: Horusec
147+
author_email: horusec@zup.com.br
148+
committer_name: Horusec
149+
committer_email: horusec@zup.com.br
147150
# This step gets the sha of last commit made, witch is the updating versioning files commit, after that creates a
148151
# branch from the origin main and cherry pick this commit on it. This process need to occur only when the release
149152
# workflow is started from a branch that isn't the main branch, for example a release branch.

deployments/mage/magefile.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ func UpdatePackageJson(version string) error {
3232
if err := sh.RunV("npm", "install", "-g", "json"); err != nil {
3333
return err
3434
}
35-
return sh.RunV("json", "-I", "-f", "./manager/package.json", "-e", `'this.version=`, version, `'`)
35+
return sh.RunV("json", "-I", "-f", "./manager/package.json", "-e", `'this.version="`+version+`"'`)
3636
}
3737

3838
func UpdateHorusecVersionInProject(actualVersion, releaseVersion string) error {
39+
dir, _ := os.Getwd()
40+
fmt.Println(dir)
3941
return sh.RunV(
40-
`find . -type f -not -path "./.git/*" -not -path "./Makefile" -not -path "./manager/cypress/*" -not -path "./manager/cypress/*" -not -name "*.sum" -not -name "*.mod"|
41-
xargs sed -i "s/` + actualVersion + `/` + releaseVersion + `/g"`)
42+
`find ./ -type f -not -path "./.git/*" -not -path "./Makefile" -not -path "./manager/cypress/*" -not -name "*.sum" -not -name "*.mod"| xargs sed -t -i "s/v2.17.1/v2.17.2/g"`)
4243
}
4344

4445
func DockerPushPlatformGoProjects(tag string) error {
@@ -107,13 +108,17 @@ func hasAllNecessaryEnvs() error {
107108
if len(result) != 0 {
108109
return fmt.Errorf("missing some env var: %v", result)
109110
}
111+
if err := os.Setenv("COSIGN_PASSWORD", os.Getenv("COSIGN_PWD")); err != nil {
112+
return err
113+
}
110114

111115
return nil
112116
}
113117

114118
func getConsingEnvs() map[string]string {
115119
return map[string]string{
116-
"COSIGN_PWD": os.Getenv("COSIGN_PWD"),
117-
"COSIGN_KEY_LOCATION": os.Getenv("COSIGN_KEY_LOCATION"),
120+
"COSIGN_PWD": os.Getenv("COSIGN_PWD"),
121+
"COSIGN_KEY": os.Getenv("COSIGN_KEY"),
118122
}
123+
119124
}

0 commit comments

Comments
 (0)