Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 7f00c9e

Browse files
jonmeliaJonathan Melia
andauthored
Migrate to GitHub Actions from Circle CI (#9)
* Migrate to GitHub Actions from Circle CI * Migrate to GitHub Actions from Circle CI * Migrate to GitHub Actions from Circle CI * Migrate to GitHub Actions from Circle CI Co-authored-by: Jonathan Melia <[email protected]>
1 parent 0008eed commit 7f00c9e

File tree

4 files changed

+162
-135
lines changed

4 files changed

+162
-135
lines changed

.circleci/config.yml

Lines changed: 0 additions & 135 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Master
2+
3+
on:
4+
push:
5+
branches:
6+
- mastercopy
7+
paths-ignore:
8+
- 'docs/**'
9+
- '*.md'
10+
11+
jobs:
12+
get-publish-version:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
publish-version: ${{ steps.get-publish-version.outputs.publish-version }}
16+
steps:
17+
- name: Prepare SemVer
18+
id: prepare-semver
19+
run: |
20+
set +o pipefail
21+
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
22+
set -o pipefail
23+
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
24+
echo "latest_version_out=$LATEST_VERSION" >> $GITHUB_OUTPUT
25+
VERSION=$(echo $LATEST_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
26+
commit_message=$( echo "${{ github.event.head_commit.message }}" | sed 's/"//g')
27+
if [[ "${commit_message,,}" == *"major release"* ]]; then
28+
echo "semver_increment='m'" >> $GITHUB_OUTPUT
29+
elif [[ "${commit_message,,}" == *"minor release"* ]]; then
30+
echo "semver_increment='i'" >> $GITHUB_OUTPUT
31+
else
32+
echo "semver_increment='p'" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Increment SemVer
36+
id: semver
37+
uses: matt-FFFFFF/[email protected]
38+
with:
39+
semver-input: ${{ steps.prepare-semver.outputs.latest_version_out }}
40+
increment: ${{ steps.prepare-semver.outputs.semver_increment }}
41+
42+
- name: Get publish version
43+
id: get-publish-version
44+
run: |
45+
echo "publish-version=${{ steps.semver.outputs.semver }}" >> $GITHUB_OUTPUT
46+
47+
48+
build-and-publish-github-release:
49+
runs-on: ubuntu-latest
50+
needs: [get-publish-version]
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v3
54+
55+
- name: Set up JDK
56+
uses: actions/setup-java@v3
57+
with:
58+
java-version: 11
59+
java-package: jdk
60+
distribution: 'temurin'
61+
62+
- name: Setup Gradle
63+
uses: gradle/gradle-build-action@v2
64+
65+
- name: Build
66+
run: |
67+
set -u
68+
set +o pipefail
69+
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
70+
set -o pipefail
71+
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
72+
VERSION=$(echo $LATEST_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
73+
VERSION_NUMBER=$(echo $VERSION | sed 's/^v\(.*\)$/\1/')
74+
sed -i -e "s/version = \"0.0.0\"/version = \"$VERSION\"/" build.gradle.kts
75+
sed -i -e "s/version = \"0.0.0\"/version = \"$VERSION\"/" gradle.properties
76+
mkdir artifacts
77+
./gradlew build --stacktrace
78+
cp build/libs/dataworks-common-logging-*.jar ./artifacts/
79+
80+
- name: Create Release
81+
id: create_release
82+
uses: actions/create-release@latest
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
with:
86+
tag_name: ${{ needs.get-publish-version.outputs.publish-version }}
87+
release_name: ${{ needs.get-publish-version.outputs.publish-version }}
88+
draft: false
89+
prerelease: false
90+
91+
- name: upload dataworks-common-logging.jar file
92+
uses: actions/upload-release-asset@v1
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
with:
96+
upload_url: ${{ steps.create_release.outputs.upload_url }}
97+
asset_path: ./artifacts/dataworks-common-logging-${{ needs.get-publish-version.outputs.publish-version }}.jar
98+
asset_name: dataworks-common-logging-${{ needs.get-publish-version.outputs.publish-version }}.jar
99+
asset_content_type: application/java-archive
100+
101+
- name: upload dataworks-common-logging-sources.jar file
102+
uses: actions/upload-release-asset@v1
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
with:
106+
upload_url: ${{ steps.create_release.outputs.upload_url }}
107+
asset_path: ./artifacts/dataworks-common-logging-${{ needs.get-publish-version.outputs.publish-version }}-sources.jar
108+
asset_name: dataworks-common-logging-${{ needs.get-publish-version.outputs.publish-version }}-sources.jar
109+
asset_content_type: application/java-archive

.github/workflows/pr.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Perform PR Build and tests
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '.github/workflows/**'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
JAVA_OPTS: "-Xmx3200m"
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v1
17+
18+
- name: Set up Python 3.7
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: 3.7
22+
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: 11
27+
java-package: jdk
28+
distribution: 'temurin'
29+
30+
- name: Setup Gradle
31+
uses: gradle/gradle-build-action@v2
32+
33+
- name: Build
34+
run: |
35+
set -u
36+
set +o pipefail
37+
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
38+
set -o pipefail
39+
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
40+
VERSION=$(echo $LATEST_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
41+
VERSION_NUMBER=$(echo $VERSION | sed 's/^v\(.*\)$/\1/')
42+
sed -i -e "s/version = \"0.0.0\"/version = \"$VERSION\"/" build.gradle.kts
43+
sed -i -e "s/version = \"0.0.0\"/version = \"$VERSION\"/" gradle.properties
44+
mkdir artifacts
45+
./gradlew build --stacktrace
46+
cp build/libs/dataworks-common-logging-*.jar ./artifacts/
47+
48+
- name: Integration tests
49+
run: |
50+
./gradlew test
51+
52+

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
}
77

88
group = "uk.gov.dwp.dataworks"
9+
version = "1.0.0"
910

1011
repositories {
1112
mavenCentral()

0 commit comments

Comments
 (0)