Skip to content

Commit

Permalink
feat: Improve the release process (#1380)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo authored Aug 11, 2023
1 parent a7c4fdc commit 0ec0dfa
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
config: ${{ steps.filter.outputs.config }}
steps:
- uses: actions/checkout@v3
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'}}
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || inputs.parent-event-name == 'release' }}
- uses: dorny/paths-filter@v2
id: filter
with:
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
cluster_outage_simulation:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.cluster_outage_simulation == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-cluster-outage-simulation' }}
if: ${{ needs.change-detection.outputs.cluster_outage_simulation == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-cluster-outage-simulation' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -131,7 +131,7 @@ jobs:

advanced_cluster:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.advanced_cluster == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-advanced-cluster' }}
if: ${{ needs.change-detection.outputs.advanced_cluster == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-advanced-cluster' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -156,7 +156,7 @@ jobs:

cluster:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.cluster == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-cluster' }}
if: ${{ needs.change-detection.outputs.cluster == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-cluster' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -181,7 +181,7 @@ jobs:

generic: # Acceptance tests that do not use any time-consuming resource (example: cluster)
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.generic == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-generic' }}
if: ${{ needs.change-detection.outputs.generic == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-generic' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
backup_online_archive:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.backup_online_archive == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-online-archive' }}
if: ${{ needs.change-detection.outputs.backup_online_archive == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-online-archive' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -235,7 +235,7 @@ jobs:

backup_snapshots:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.backup_snapshots == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-snapshots' }}
if: ${{ needs.change-detection.outputs.backup_snapshots == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-snapshots' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -262,7 +262,7 @@ jobs:

backup_schedule:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.backup_schedule == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-schedule' }}
if: ${{ needs.change-detection.outputs.backup_schedule == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-backup-schedule' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -288,7 +288,7 @@ jobs:
run: make testacc
project:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.project == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-project' }}
if: ${{ needs.change-detection.outputs.project == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-project' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -316,7 +316,7 @@ jobs:
run: make testacc
serverless:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.serverless == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-serverless' }}
if: ${{ needs.change-detection.outputs.serverless == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-serverless' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -341,7 +341,7 @@ jobs:
run: make testacc
network:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.network == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-network' }}
if: ${{ needs.change-detection.outputs.network == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-network' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -370,7 +370,7 @@ jobs:
run: make testacc
config:
needs: [ change-detection ]
if: ${{ needs.change-detection.outputs.config == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-config' }}
if: ${{ needs.change-detection.outputs.config == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-config' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
44 changes: 34 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,55 @@ on:
tags:
- 'v*'
jobs:
# Check that the last run of the acceptance tests was successful
# We run the acceptance tests only if the last run of the sceduled workflow failed
check-acceptance-tests-status:
runs-on: ubuntu-latest
outputs:
acceptance_tests_status: ${{ steps.lastJobStatus.outputs.test }}
steps:
- name: Check last job status
id: lastJobStatus
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LAST_JOB_STATUS=$(gh run list --workflow acceptance-tests.yml |grep -oh "completed.*" | grep -h "schedule.*" | head -1 | awk '{print $2}')
echo "acceptanceTestsStatus=${LAST_JOB_STATUS}" >> $GITHUB_OUTPUT
# We run the acceptance tests only if the last run of the sceduled workflow failed
run-accettance-tests-workflow:
needs: [ check-acceptance-tests-status ]
if: ${{ needs.check-acceptance-tests-status.outputs.acceptance_tests_status != 'success'}}
secrets: inherit
permissions:
contents: write
pull-requests: read
repository-projects: read
uses: ./.github/workflows/acceptance-tests.yml
with:
parent-event-name: 'release'
# Release the provider
goreleaser:
runs-on: ubuntu-latest
needs: [ check-acceptance-tests-status, run-accettance-tests-workflow ]
if: always() && !cancelled() && !failure()
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Unshallow
- name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
-
name: Import GPG key
- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
- name: Set the user terminal
run: export GPG_TTY=$(tty)
-
name: Run GoReleaser
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
Expand Down
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ signs:
- "--detach-sign"
- "${artifact}"
release:
draft: true
name_template: "{{.Version}}"
prerelease: auto
changelog:
skip: false
sort: asc
Expand Down
16 changes: 6 additions & 10 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
### Pre-release the provider
We pre-release the provider to make for testing purpose. **A Pre-release is not published to the Hashicorp Terraform Registry**.

- Open the GitHub repository release page and click draft a new release
- Fill the pre-release tag and select `master` as the target branch

<img width="370" alt="image2" src="https://github.com/mongodb/terraform-provider-mongodbatlas/assets/5663078/e710c0ff-dc00-44c2-9eb6-146cd791d47e">
- Generate Release Notes: Click Generate release notes button to populate release notes
- Set publishing to Pre-release

<img width="477" alt="image3" src="https://github.com/mongodb/terraform-provider-mongodbatlas/assets/5663078/30d2db83-6b2d-4eb2-9da6-93fc34d64c09">

- **There is a bug in the GitHub release page**: after binaries get created, GitHub flips backthe status of release as Draft so you have to set it to Pre-Release (or Latest, if publishing the final version) again.
- Create and push the pre-release tag (`X.Y.Z-pre`) to master
```bash
git tag [YOUR_TAG]-pre
git push origin [YOUR_TAG]-pre
```
- You will see the release in the [GitHub Release page](https://github.com/mongodb/terraform-provider-mongodbatlas/releases) once the [release action](.github/workflows/release.yml) has completed.

### Generate the CHANGELOG.md
We use a tool called [github changelog generator](https://github.com/github-changelog-generator/github-changelog-generator) to automatically update our changelog. It provides options for downloading a CLI or using a docker image with interactive mode to update the CHANGELOG.md file locally.
Expand Down

0 comments on commit 0ec0dfa

Please sign in to comment.