|
1 | 1 | name: release |
| 2 | +run-name: Release by @${{ github.actor }} from ${{ github.ref_name }} |
2 | 3 |
|
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 |
14 | 9 |
|
15 | 10 | jobs: |
16 | 11 | 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 |
0 commit comments