From 7d9dedb80fa5e5f7ea281e7ffea2f79a99ebf0a5 Mon Sep 17 00:00:00 2001 From: Oliver Rau Date: Tue, 18 Jul 2023 15:55:47 +0200 Subject: [PATCH] build: Add build scripts Signed-off-by: Oliver Rau --- .github/build.yml | 85 +++++++++++++++++++++++++++++++++++++++++++++++ .releaserc | 67 +++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 .github/build.yml create mode 100644 .releaserc diff --git a/.github/build.yml b/.github/build.yml new file mode 100644 index 0000000..c799f98 --- /dev/null +++ b/.github/build.yml @@ -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 }} + diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..80d8833 --- /dev/null +++ b/.releaserc @@ -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" + } + ] +} \ No newline at end of file