Skip to content

fix: add fetch filter flags #26

fix: add fetch filter flags

fix: add fetch filter flags #26

name: Build & Release
on:
push:
branches: [main]
env:
ARTIFACT_NAME: smgr
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.20.3'
check-latest: true
cache-dependency-path: smgr/go.sum
- name: Add integration test config
run: |
echo -e "OWNER: 13013SwagR\nREPO: semver-manager-test\nTOKEN: ${{ secrets.GITHUB_TOKEN }}" > src/cmd/fetch/fetch_test.yaml
- run: cd src; go test ./... -cover
build:
runs-on: ubuntu-latest
outputs:
BUILD_ID: ${{ steps.build_number.outputs.BUILD_ID }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.20.3'
check-latest: true
cache-dependency-path: src/go.sum
- name: Generate BUILD_ID
id: build_number
run: |
echo "BUILD_ID=$(echo ${GITHUB_SHA} | cut -c1-7)-$(date '+%Y%m%dT%H%M%S')" >> $GITHUB_OUTPUT
- name: Create artifact
run: |
cd src; go build -o ../${{ env.ARTIFACT_NAME }}-${{ steps.build_number.outputs.BUILD_ID }} ./cmd/smgr
- name: validate build artifact creation
run: ls -al
- name: Upload a Build Artifact
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v2.3.0
with:
name: ${{ env.ARTIFACT_NAME }}-${{ steps.build_number.outputs.BUILD_ID }}
path: ${{ env.ARTIFACT_NAME }}-${{ steps.build_number.outputs.BUILD_ID }}
##### release ##################################################################################################
release:
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
needs: [build, tests]
outputs:
RELEASE_VERSION: ${{ steps.release_version.outputs.RELEASE_VERSION }}
VERSION_TAG: ${{ steps.new_version.outputs.version_tag }}
steps:
- name: Pull all git tags/releases
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download artifact ${{ env.ARTIFACT_NAME }}-${{ needs.build.outputs.BUILD_ID }}
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}-${{ needs.build.outputs.BUILD_ID }}
- name: Get Commit Version Increment
uses: Bluepr-nt/Commit-Increment@main
id: increment
with:
major_pattern: "^((build|ci|docs|feat|fix|perf|refactor|test)(\([a-z 0-9,.\-]+\))?!: [\w \(\),:.;\-#&']+|\nBREAKING CHANGES: [\w \(\),:.;\-#&']+)$"

Check failure on line 74 in .github/workflows/on-push-to-main.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/on-push-to-main.yaml

Invalid workflow file

You have an error in your yaml syntax on line 74
minor_pattern: "^(feat)(\([a-z 0-9,.\-]+\))?!?: [\w \(\),:.;\-#&']+$"
- name: Generate new semver compliant version
id: new_version
run: |
# Use current semver-manager to generate the version
# Fetch the git tags
git fetch --tags
# List the git tags in comma speparated format
TAGS=$(git tag -l | tr '\n' ',')
# Build the smgr binary
go build -o smgr ./cmd/smgr/
# Generate the new version using smgr
NEW_VERSION=$(./src/smgr increment --source-versions $TAGS --level ${{ steps.increment.outputs.increment }})
echo "version_tag=$(echo $NEW_VERSION | cut -d '+' -f 1)" >> $GITHUB_OUTPUT
- name: Set release version with pattern <version_tag>+<commits_increment>-<build_number>
id: release_version
run: echo "RELEASE_VERSION=${{ steps.new_version.outputs.version_tag }}+${{ steps.increment.outputs.increment }}-${{ needs.build.outputs.BUILD_ID }}" >> $GITHUB_OUTPUT
- name: Tag artifact file
run: mv ${{ env.ARTIFACT_NAME }}-${{ needs.build.outputs.BUILD_ID }} ${{ env.ARTIFACT_NAME }}-${{ steps.release_version.outputs.RELEASE_VERSION }}
- name: Check if tag/release exists
id: release_exists
run: |
echo "RELEASE_EXISTS=$(git tag -l | grep ${{ steps.release_version.outputs.RELEASE_VERSION }})" >> $GITHUB_OUTPUT
- name: Create tag
if: ${{ !env.ACT }}
run: git tag ${{ steps.new_version.outputs.version_tag }} && git push --tags
- name: Install git-release-notes
run: npm install -g git-release-notes
- name: Generate release notes for the first release
if: ${{ !steps.release_exists.outputs.RELEASE_EXISTS }}
run: git-release-notes $(git rev-list --max-parents=0 HEAD)..$(git log -1 --pretty=format:"%H") markdown > changelog.md
- name: Generate release notes
if: ${{ steps.release_exists.outputs.RELEASE_EXISTS }}
run: git-release-notes $(git tag -l --sort=-version:refname | head -n 2 | tail -1 )..${{ steps.new_version.outputs.version_tag }} markdown > changelog.md
- name: Create Github release
if: ${{ !env.ACT }}
uses: ncipollo/release-action@v1
with:
bodyFile: changelog.md
artifacts: "${{ env.ARTIFACT_NAME }}-${{ steps.release_version.outputs.RELEASE_VERSION }}"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: false
artifactErrorsFailBuild: true
draft: false
name: ${{ env.ARTIFACT_NAME }} ${{ steps.release_version.outputs.RELEASE_VERSION }} # name of the release
replacesArtifacts: false
removeArtifacts: false
tag: ${{ steps.new_version.outputs.version_tag }}