Skip to content

Commit e4076ce

Browse files
Merge pull request #470 from nextmv-io/feature/new-release-workflow
New release workflow
2 parents 1620c5d + 54dade2 commit e4076ce

File tree

7 files changed

+78
-127
lines changed

7 files changed

+78
-127
lines changed

.github/workflows/go-lint.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
jobs:
77
sdk-go-lint:
88
runs-on: ubuntu-latest
9+
env:
10+
GO_VERSION: 1.24
911
# Use a matrix strategy to test all the modules simultaneously.
1012
strategy:
1113
fail-fast: false
@@ -22,12 +24,6 @@ jobs:
2224
- name: git clone
2325
uses: actions/checkout@v4
2426

25-
- name: determine Go version
26-
run: |
27-
export GO_VERSION=$(cat workflow-configuration.yml | yq '.go-version' -r)
28-
echo "Using Go version $GO_VERSION"
29-
echo "GO_VERSION=${GO_VERSION}" >> $GITHUB_ENV
30-
3127
- name: set up go
3228
uses: actions/setup-go@v5
3329
with:

.github/workflows/go-test.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
jobs:
77
sdk-go-build-test:
88
runs-on: ubuntu-latest
9+
env:
10+
GO_VERSION: 1.24
911
# Use a matrix strategy to test all the modules simultaneously.
1012
strategy:
1113
fail-fast: false
@@ -23,13 +25,6 @@ jobs:
2325
- name: git clone
2426
uses: actions/checkout@v4
2527

26-
# Determines the Go version to use.
27-
- name: determine Go version
28-
run: |
29-
export GO_VERSION=$(cat workflow-configuration.yml | yq '.go-version' -r)
30-
echo "Using Go version $GO_VERSION"
31-
echo "GO_VERSION=${GO_VERSION}" >> $GITHUB_ENV
32-
3328
# Sets up Go with the version set before.
3429
- name: set up go
3530
uses: actions/setup-go@v5

.github/workflows/release.yml

Lines changed: 27 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,32 @@
11
name: release
2+
run-name: Release by @${{ github.actor }} from ${{ github.ref_name }}
23

3-
on:
4-
workflow_dispatch:
5-
inputs:
6-
VERSION:
7-
description: "The version to release"
8-
required: true
9-
IS_PRE_RELEASE:
10-
description: "It IS a pre-release"
11-
required: true
12-
default: true
13-
type: boolean
4+
on: [push]
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
149

1510
jobs:
1611
release:
17-
runs-on: ubuntu-latest
18-
env:
19-
VERSION: ${{ inputs.VERSION }}
20-
GH_TOKEN: ${{ github.token }}
21-
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
22-
permissions:
23-
contents: write
24-
steps:
25-
- name: ensure proper tagging
26-
run: |
27-
echo "If it's a pre-release, the version should contain a hyphen"
28-
if [ ${{ inputs.IS_PRE_RELEASE }} = true ]; then
29-
if [[ $VERSION != *-* ]]; then
30-
echo "Pre-release versions should contain a hyphen"
31-
exit 1
32-
fi
33-
else
34-
if [[ $VERSION == *-* ]]; then
35-
echo "Release versions should not contain a hyphen"
36-
exit 1
37-
fi
38-
fi
39-
40-
- name: configure git and clone
41-
run: |
42-
mkdir -p ~/.ssh
43-
ssh-keyscan github.com >> ~/.ssh/known_hosts
44-
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
45-
ssh-add - <<< "${{ secrets.NEXTMVBOT_SSH_KEY }}"
46-
47-
echo "${{ secrets.NEXTMVBOT_SIGNING_KEY }}" > ~/.ssh/signing.key
48-
chmod 600 ~/.ssh/signing.key
49-
50-
git config --global user.name "nextmv-bot"
51-
git config --global user.email "tech+gh-nextmv-bot@nextmv.io"
52-
git config --global gpg.format ssh
53-
git config --global user.signingkey ~/.ssh/signing.key
54-
55-
git clone git@github.com:nextmv-io/sdk.git
56-
57-
cd sdk
58-
git checkout ${{ github.ref_name }}
59-
60-
git rev-parse --short HEAD
61-
62-
- name: determine Go version
63-
run: |
64-
export GO_VERSION=$(cat workflow-configuration.yml | yq '.go-version' -r)
65-
echo "Using Go version $GO_VERSION"
66-
echo "GO_VERSION=${GO_VERSION}" >> $GITHUB_ENV
67-
working-directory: ./sdk
68-
69-
- name: set up Go
70-
uses: actions/setup-go@v5
71-
with:
72-
go-version: ${{ env.GO_VERSION }}
73-
cache-dependency-path: |
74-
**/go.sum
75-
**/go.mod
76-
77-
- name: push release tag
78-
run: |
79-
git tag -s $VERSION -m "Release $VERSION"
80-
git push origin $VERSION
81-
working-directory: ./sdk
82-
83-
- name: bump and tag nested modules
84-
run: |
85-
export MODULES=$(cat workflow-configuration.yml | yq '.nested_modules[]' -r)
86-
for module in $MODULES; do
87-
echo "Bumping $module to $VERSION"
88-
pushd $module
89-
go get github.com/nextmv-io/sdk@$VERSION
90-
go mod tidy
91-
popd
92-
done
93-
git add --all
94-
git commit -S -m "Bump nested modules to $VERSION"
95-
git push
96-
for module in $MODULES; do
97-
git tag -s $module/$VERSION -m "Release $module/$VERSION"
98-
git push origin $module/$VERSION
99-
done
100-
working-directory: ./sdk
101-
102-
- name: create release
103-
run: |
104-
PRERELEASE_FLAG=""
105-
if [ ${{ inputs.IS_PRE_RELEASE }} = true ]; then
106-
PRERELEASE_FLAG="--prerelease"
107-
fi
108-
109-
gh release create $VERSION \
110-
--verify-tag \
111-
--generate-notes \
112-
--title $VERSION $PRERELEASE_FLAG
113-
working-directory: ./sdk
114-
115-
- name: notify slack
116-
if: ${{ inputs.IS_PRE_RELEASE == false }}
117-
run: |
118-
export DATA="{\"text\":\"Release notification - sdk $VERSION (see <https://github.com/nextmv-io/sdk/releases/$VERSION|release notes>)\"}"
119-
curl -X POST -H 'Content-type: application/json' --data "$DATA" ${{ secrets.SLACK_URL_MISSION_CONTROL }}
12+
if: ${{ github.ref_type == 'branch' }}
13+
uses: nextmv-io/release/.github/workflows/release.yml@feature/develop
14+
with:
15+
BRANCH: ${{ github.ref_name }}
16+
REPOSITORY: sdk
17+
LANGUAGE: go
18+
PACKAGE_NAME: sdk
19+
PACKAGE_LOCATION: ./
20+
VERSION_FILE: VERSION
21+
POST_RELEASE_COMMAND: bash .nextmv/post-release.sh
22+
secrets: inherit
23+
24+
notify:
25+
needs: [release]
26+
if: ${{ needs.release.outputs.RELEASE_NEEDED == 'true' && needs.release.outputs.SHOULD_NOTIFY_SLACK == 'true' }}
27+
uses: nextmv-io/release/.github/workflows/notify-slack.yml@develop
28+
with:
29+
PACKAGE_NAME: sdk
30+
VERSION: ${{ needs.release.outputs.VERSION }}
31+
REPOSITORY: sdk
32+
secrets: inherit

.nextmv/post-release.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export MODULES=$(cat "$(dirname "$0")/workflow-configuration.yml" | yq '.nested_modules[]' -r)
2+
3+
git checkout -b feature/bump-nested-$VERSION
4+
5+
for module in $MODULES; do
6+
echo "Bumping $module to $VERSION"
7+
pushd $module
8+
go get github.com/nextmv-io/sdk@$VERSION
9+
go mod tidy
10+
git add go.mod go.sum
11+
popd
12+
done
13+
14+
git commit -S -m "Bump nested modules after $VERSION release"
15+
git push origin --set-upstream feature/bump-nested-$VERSION
16+
17+
OUTPUT=$(gh pr create --base $BRANCH --title "Bump nested modules after $VERSION release" --body "Automated bump of nested modules to version $VERSION")
18+
19+
echo "# :rocket: PR created" >> $GITHUB_STEP_SUMMARY
20+
echo "" >> $GITHUB_STEP_SUMMARY
21+
echo "Bump nested modules :arrow_right: [PR Link](${OUTPUT})." >> $GITHUB_STEP_SUMMARY

RELEASE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Release
2+
3+
A reusable workflow is used to release the package. Nextmv team members: please
4+
go to the corresponding repository for more information.
5+
6+
## Stable release
7+
8+
Open a PR against the `develop` branch with the following change:
9+
10+
* Update the version in the `VERSION` file.
11+
12+
After the PR is merged, the `release.yml` workflow will be triggered and it
13+
will automatically create a release.
14+
15+
After the release is created, a new PR will be opened bumping the nested
16+
modules to the new version. Make sure you approve and merge this new PR.
17+
18+
## Pre-release
19+
20+
Update the version in the `VERSION` file to a dev tag. When a commit is pushed,
21+
the `release.yml` workflow will be triggered and it will automatically create a
22+
release.
23+
24+
After the release is created, a new PR will be opened bumping the nested
25+
modules to the new version. Make sure you approve and merge this new PR.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.9.2-dev.6

0 commit comments

Comments
 (0)