Skip to content

Commit 09247c9

Browse files
committed
add release workflow and update module
1 parent dc4ff9e commit 09247c9

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

.github/workflows/release.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: 'New Release'
2+
run-name: 'Release ${{ inputs.version_number }} (use existing tag: ${{ inputs.use_existing_tag}})'
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version_number:
8+
description: 'Version number (e.g., v1.0.0, v1.0.0-pre, v1.0.0-pre1)'
9+
required: true
10+
use_existing_tag:
11+
description: 'Set value to `true` to use an existing tag for the release process, default is `false`'
12+
default: 'false'
13+
14+
jobs:
15+
16+
release-config:
17+
runs-on: ubuntu-latest
18+
permissions: {}
19+
outputs:
20+
creates_new_tag: ${{ steps.evaluate_inputs.outputs.creates_new_tag }}
21+
steps:
22+
- id: evaluate_inputs
23+
run: |
24+
{
25+
echo "creates_new_tag=$(if [ '${{ inputs.use_existing_tag }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)"
26+
} >> "$GITHUB_OUTPUT"
27+
28+
validate-inputs:
29+
runs-on: ubuntu-latest
30+
permissions: {}
31+
steps:
32+
- name: Validation of version format
33+
run: |
34+
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
35+
- name: Checkout
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
37+
with:
38+
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }
39+
40+
create-tag:
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write
44+
needs: [ release-config, validate-inputs ]
45+
if: >-
46+
!cancelled()
47+
&& !contains(needs.*.result, 'failure')
48+
&& needs.release-config.outputs.creates_new_tag == 'true'
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
52+
with:
53+
ref: 'master'
54+
- name: Get the latest commit SHA
55+
id: get-sha
56+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
57+
- name: Create release tag
58+
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72
59+
with:
60+
tag: ${{ inputs.version_number }}
61+
commit_sha: ${{ steps.get-sha.outputs.sha }}
62+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
63+
gpg_passphrase: ${{ secrets.PASSPHRASE }}
64+
65+
release:
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
needs: [ validate-inputs, create-tag ]
70+
if: >-
71+
!cancelled()
72+
&& !contains(needs.*.result, 'failure')
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
76+
with:
77+
ref: ${{ inputs.version_number }}
78+
- name: Set up Go
79+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34
80+
with:
81+
go-version-file: 'go.mod'
82+
- name: Import GPG key
83+
id: import_gpg
84+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5
85+
with:
86+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
87+
passphrase: ${{ secrets.PASSPHRASE }}
88+
- name: Run GoReleaser
89+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
90+
with:
91+
version: '~> v2'
92+
args: release --clean
93+
env:
94+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module go.mongodb.org/atlas-appservices
1+
module github.com/mongodb-labs/go-client-mongodb-atlas-app-services
22

33
go 1.23
44

0 commit comments

Comments
 (0)