Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

chore: move release process to a GitHub Actions workflow #150

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/workflows/maven-publish.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: generate-release
# This workflow will generate changelog and release notes.
# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml

on:
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Release
uses: cycjimmy/[email protected]
with:
semantic_version: 19.0.5
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: equinix-labs@auto-commit-workflow
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: equinix-labs@auto-commit-workflow
GIT_COMMITTER_EMAIL: [email protected]
42 changes: 42 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"branches": [
"main"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo -n '${nextRelease.version}' > version && make generate",
"publishCmd": "mvn -f equinix-openapi-metal -B package && mvn -f equinix-openapi-metal deploy -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/equinix-labs/metal-java"
}
],
[
"@semantic-release/git",
{
"message": "ci: regenerate code for version ${nextRelease.version}",
"assets": ["."]
}
]
]
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ OPENAPI_URL=https://api.equinix.com/metal/v1/api-docs
GIT_ORG=equinix-labs
GIT_REPO=metal-java

PACKAGE_VERSION=$(shell cat version)

# Equinix Metal OAS 3.0.0
OPENAPI_CONFIG:=spec/oas3.config.json
OPENAPI_GENERATED_CLIENT=equinix-openapi-metal/
Expand Down Expand Up @@ -47,6 +49,8 @@ pull:

codegen:
${DOCKER_OPENAPI} generate \
--http-user-agent "${GIT_REPO}/${PACKAGE_VERSION}" \
-p artifactVersion=${PACKAGE_VERSION} \
-i /local/${PATCHED_SPEC_ENTRY_POINT} \
-g java \
-c /local/${OPENAPI_CONFIG} \
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ make generate
```

## Contribution guidelines

### Patching oas3.0 spec
1. Make changes in ``spec/oas3.patched/`` dir.
2. Create a patch file in metal-java:
Expand Down Expand Up @@ -74,3 +75,17 @@ Complex workflows requiring multiple granular, autogenerated apis can be impleme
4. If using environment variables, they can be added in Java options.
4. Alternatively, you can do step iii through terminal directly.
4. For every new functional test, a separate github workflow .yaml should be defined inside ```.github/workflows```. These can be run from Github's actions UI directly. Check existing workflow definitions for reference.

## Release

This SDK is released via [an on-demand GitHub Actions workflow](https://github.com/equinix-labs/metal-go/actions/workflows/release.yaml).

When that workflow is run, it steps through the release process in roughly this order:

1. Determine the version number of the previous GitHub release
2. Identify Conventional Commit tags in the commit log since the previous release
3. Use the Conventional Commit tags to calculate the correct next version
4. Write the next version to the `version` file and regenerate the code
5. Commit the updated `version` and code
6. Create a GitHub release using the value in `version` for the tag & title
7. Rebuild SDK JARs and publish them to [this repo's packages page](https://github.com/equinix-labs/metal-java/packages/)
2 changes: 0 additions & 2 deletions spec/oas3.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"groupId": "com.equinix",
"artifactId": "equinix-openapi-metal",
"artifactVersion": "0.7.0",
"httpUserAgent": "metal-java/0.7.0",
"library": "okhttp-gson",
"invokerPackage": "com.equinix.openapi",
"modelPackage": "com.equinix.openapi.metal.v1.model",
Expand Down
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7.0