Skip to content

Commit

Permalink
build: Add build scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Rau <oliver.rau@de.ibm.com>
  • Loading branch information
olira committed Jul 18, 2023
1 parent aa0f043 commit 7d9dedb
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: fp-go CI

on:
push:
branches:
- main

pull_request:

workflow_dispatch:
inputs:
dryRun:
description: 'Dry-Run'
default: 'true'
required: false

env:
# Currently no way to detect automatically
DEFAULT_BRANCH: main
GO_VERSION: 1.20.5 # renovate: datasource=golang-version depName=golang
NODE_VERSION: 18
DRY_RUN: true

jobs:
build:
runs-on: ubuntu-latest
steps:
# full checkout for semantic-release
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- name: Set up go ${{env.GO_VERSION}}
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}
-
name: Tests
run: |
go mod tidy
go test -v ./...
release:
needs: [build]
if: github.repository == 'IBM/fp-go' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
issues: write
pull-requests: write

steps:
# full checkout for semantic-release
- name: Full checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
with:
node-version: ${{ env.NODE_VERSION }}

- name: Set up go ${{env.GO_VERSION}}
uses: actions/setup-go@v4
with:
go-version: ${{env.GO_VERSION}}

# The dry-run evaluation is only made for non PR events. Manual trigger w/dryRun true, main branch and any tagged branches will set DRY run to false
- name: Check dry run
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" && "${{ github.event.inputs.dryRun }}" != "true" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" == "refs/heads/${{env.DEFAULT_BRANCH}}" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" =~ ^refs/heads/v[0-9]+(\.[0-9]+)?$ ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
fi
- name: Semantic Release
run: |
npx -p conventional-changelog-conventionalcommits semantic-release --dry-run ${{env.DRY_RUN}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

67 changes: 67 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"releasedLabels": false
}
]
],
"analyzeCommits": {
"releaseRules": [
{
"type": "build",
"release": "patch"
}
]
},
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "chore",
"section": "Miscellaneous Chores"
},
{
"type": "refactor",
"section": "Code Refactoring"
},
{
"type": "test",
"section": "Tests"
},
{
"type": "build",
"section": "Build System"
}
]
},
"tagFormat": "v${version}",
"branches": [
{
"name": "main"
}
]
}

0 comments on commit 7d9dedb

Please sign in to comment.