This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update workflows for release + versioning
- Loading branch information
Showing
4 changed files
with
126 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,69 +7,16 @@ on: | |
types: | ||
- closed | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
# Cancel any active builds when new commits are pushed | ||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
bump_and_tag: | ||
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') | ||
runs-on: ubuntu-latest | ||
environment: Production | ||
services: | ||
postgres: | ||
image: postgres:14.5 | ||
env: | ||
POSTGRES_USER: tester | ||
POSTGRES_PASSWORD: pgtestpw | ||
POSTGRES_DB: l0_storage | ||
POSTGRES_PORT: 5432 | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 19 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '19' | ||
distribution: 'zulu' | ||
|
||
- name: Install CLI | ||
uses: dopplerhq/cli-action@v2 | ||
|
||
- name: Install PostgreSQL client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes postgresql-client | ||
- name: Create Tables | ||
run: psql -h localhost -d l0_storage -U tester -f database/create_tables.sql | ||
env: | ||
PGPASSWORD: pgtestpw | ||
|
||
- name: Maven Package | ||
run: doppler run -c tst -- mvn clean package | ||
env: | ||
DOPPLER_TOKEN: ${{ secrets.DOPPLER_ST }} | ||
|
||
- name: Bump Version | ||
id: bump-version | ||
uses: RichardInnocent/[email protected] | ||
with: | ||
access-token: ${{ secrets.github_token }} | ||
version-prefix: | ||
|
||
outputs: | ||
version: ${{ steps.bump-version.outputs.new-version }} | ||
test_and_push: | ||
runs-on: ubuntu-latest | ||
needs: bump_and_tag | ||
|
@@ -94,10 +41,10 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 19 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '19' | ||
java-version: '20' | ||
distribution: 'zulu' | ||
|
||
- name: Install CLI | ||
|
@@ -126,20 +73,28 @@ jobs: | |
- name: Registry login | ||
run: doctl registry login --expiry-seconds 600 | ||
|
||
- name: Mvn project version | ||
id: version | ||
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: | | ||
registry.digitalocean.com/tiki/l0-storage:${{ needs.bump_and_tag.outputs.version }} | ||
registry.digitalocean.com/tiki/l0-storage:${{ steps.version.outputs.version }} | ||
registry.digitalocean.com/tiki/l0-storage:latest | ||
build-args: | | ||
JAR_FILE=target/*.jar | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
|
||
deploy_to_infra: | ||
runs-on: ubuntu-latest | ||
needs: [ bump_and_tag, test_and_push ] | ||
needs: [ test_and_push ] | ||
environment: Production | ||
steps: | ||
- name: Checkout | ||
|
@@ -171,6 +126,7 @@ jobs: | |
id: apply | ||
run: terraform apply -auto-approve | ||
working-directory: infra | ||
|
||
sentry_release: | ||
runs-on: ubuntu-latest | ||
needs: deploy_to_infra | ||
|
@@ -189,9 +145,10 @@ jobs: | |
environment: public | ||
ignore_missing: true | ||
ignore_empty: true | ||
|
||
publish_docs: | ||
runs-on: ubuntu-latest | ||
needs: [ sentry_release, bump_and_tag ] | ||
needs: [ sentry_release, test_and_push ] | ||
environment: Production | ||
steps: | ||
- name: Checkout | ||
|
@@ -200,9 +157,9 @@ jobs: | |
- name: OpenApi | ||
uses: readmeio/[email protected] | ||
with: | ||
rdme: openapi docs/openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6379efc05c98fc002512b213 | ||
rdme: openapi openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6379efc05c98fc002512b213 | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag_name: ${{ needs.bump_and_tag.outputs.version }} | ||
tag: ${{ needs.test_and_push.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Version | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
# Cancel any active builds when new commits are pushed | ||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
Version: | ||
if: startsWith(github.head_ref, 'release/') | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:14.5 | ||
env: | ||
POSTGRES_USER: tester | ||
POSTGRES_PASSWORD: pgtestpw | ||
POSTGRES_DB: l0_storage | ||
POSTGRES_PORT: 5432 | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '20' | ||
distribution: 'zulu' | ||
|
||
- name: Checkout PR | ||
id: getpr | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh pr checkout ${{ github.event.pull_request.number }} | ||
export PR_BRANCH=$(git branch --show-current) | ||
echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT | ||
- name: Get Version | ||
id: semver | ||
uses: ietf-tools/semver-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
branch: ${{ steps.getpr.outputs.branch }} | ||
|
||
- name: Set Version | ||
run: | | ||
sed -i '0,/<version>*.*.*<\/version>/s//<version>${{ steps.semver.outputs.nextStrict }}<\/version>/' pom.xml | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '20' | ||
distribution: 'zulu' | ||
|
||
- name: Install CLI | ||
uses: dopplerhq/cli-action@v2 | ||
|
||
- name: Install PostgreSQL client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes postgresql-client | ||
- name: Create Tables | ||
run: psql -h localhost -d l0_storage -U tester -f database/create_tables.sql | ||
env: | ||
PGPASSWORD: pgtestpw | ||
|
||
- name: OAS3 | ||
run: doppler run -c tst -- mvn clean verify | ||
env: | ||
DOPPLER_TOKEN: ${{ secrets.DOPPLER_ST }} | ||
|
||
- name: Commit Changes | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GH Action" | ||
git add pom.xml | ||
git add openapi.yaml | ||
git commit -m 'version bump' | ||
git push | ||
outputs: | ||
version: ${{ steps.semver.outputs.nextStrict }} |