From 84cd4cb400b58f2209d0af602fa074c9c391a714 Mon Sep 17 00:00:00 2001 From: Kilian PAQUIER Date: Wed, 8 May 2024 10:37:05 +0000 Subject: [PATCH] ci: update layout and ci dependencies --- .craft | 4 +++ .github/dependabot.yml | 2 +- .github/workflows/codeql.yml | 10 ++++++ .github/workflows/dependencies.yml | 10 ++++++ .github/workflows/integration.yml | 18 ++++++----- .github/workflows/release.yml | 49 ++++++++++++++++-------------- 6 files changed, 62 insertions(+), 31 deletions(-) diff --git a/.craft b/.craft index c5f78f4..5e24d76 100644 --- a/.craft +++ b/.craft @@ -2,6 +2,10 @@ --- ci: name: github + release: + auto: false + backmerge: false + mode: github-token options: - codecov - codeql diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 06f086a..c7b0d84 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -34,6 +34,6 @@ updates: - patch commit-message: include: scope - prefix: ci + prefix: chore reviewers: - kilianpaquier \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 86c3dc1..c4a892e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,6 +18,16 @@ on: push: branches: - main + - master + - staging + - dev + - develop + - development + - next + - beta + - alpha + - v[0-9]+.x + - v[0-9]+.[0-9]+.x jobs: codeql: diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index c39fa66..0331b86 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -7,6 +7,16 @@ on: push: branches: - main + - master + - staging + - dev + - develop + - development + - next + - beta + - alpha + - v[0-9]+.x + - v[0-9]+.[0-9]+.x permissions: contents: write diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 402c0a9..d3612f1 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,15 +12,17 @@ on: - ready_for_review push: branches: - - alpha - - beta - - develop - main - - next + - master - staging - # unnecessary to espace '.' - # see https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet - - v[0-9]+(.[0-9]+)? + - dev + - develop + - development + - next + - beta + - alpha + - v[0-9]+.x + - v[0-9]+.[0-9]+.x workflow_dispatch: jobs: @@ -61,7 +63,7 @@ jobs: go-version-file: go.mod token: ${{ secrets.GITHUB_TOKEN }} - run: mkdir -p reports/ - - uses: golangci/golangci-lint-action@v5 + - uses: golangci/golangci-lint-action@v6 with: args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c95f53..00f18ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,6 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 - - id: sha - run: echo "sha=$(echo "$GITHUB_REF_NAME" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT # https://github.com/marketplace/actions/action-for-semantic-release - id: semantic_release continue-on-error: true @@ -47,33 +45,38 @@ jobs: branches: | [ "(master|main)", - "v+([0-9])?(.+([0-9]))", + "v+([0-9])?(.{+([0-9]),x}).x", { "name": "next", "prerelease": true }, { "name": "beta", "prerelease": true }, { "name": "alpha", "prerelease": true }, { "name": "staging", "prerelease": "beta" }, - { "name": "develop", "prerelease": "alpha" } + { "name": "(dev|develop|development)", "prerelease": "alpha" } ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: release run: | - if [ "$RELEASED" = "true" ]; then - echo "version=v$NEW_VERSION" >> $GITHUB_OUTPUT - elif [ "$LAST_VERSION" != "" ]; then - echo "version=v${LAST_VERSION}-${BRANCH_SHA}" >> $GITHUB_OUTPUT - else - echo "version=v0.0.0-dev.${BRANCH_SHA}" >> $GITHUB_OUTPUT - fi + SHA=$(echo "${GITHUB_REF_NAME}" | sha256sum | cut -c -8) - if [[ $NEW_VERSION =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then - echo "release=true" >> $GITHUB_OUTPUT + if echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}.*$"; then + echo "version=v$SEMREL_INFO_NEXT_VERSION" >> $GITHUB_OUTPUT + echo "$SEMREL_INFO_NEXT_VERSION" | grep -Eq "^[0-9]+(\.[0-9]+){2}$" && echo "release=true" >> $GITHUB_OUTPUT + exit 0 fi + + git fetch --tags + + SEARCH="" # see .gitlab/version.yml.tmpl - may evolve in the future + + SEMREL_INFO_LAST_VERSION=$(git tag --list | sort -V | grep -E "${SEARCH}" | tail -n1) + + SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_LAST_VERSION-1.0.0} + SEMREL_INFO_NEXT_VERSION=${SEMREL_INFO_NEXT_VERSION%-*} + + echo "version=v${SEMREL_INFO_NEXT_VERSION#v}-build.${SHA}" >> $GITHUB_OUTPUT env: - BRANCH_SHA: ${{ steps.sha.outputs.sha }} - LAST_VERSION: ${{ steps.semantic_release.outputs.last_release_version }} - NEW_VERSION: ${{ steps.semantic_release.outputs.new_release_version }} - RELEASED: ${{ steps.semantic_release.outputs.new_release_published }} + SEMREL_INFO_LAST_VERSION: ${{ steps.semantic_release.outputs.last_release_version }} + SEMREL_INFO_NEXT_VERSION: ${{ steps.semantic_release.outputs.new_release_version }} - run: echo $VERSION env: VERSION: ${{ steps.release.outputs.version }} @@ -83,10 +86,12 @@ jobs: runs-on: ubuntu-latest if: github.ref_protected == true environment: release + permissions: + contents: write + issues: write + pull-requests: write steps: - uses: actions/checkout@v4 - with: - persist-credentials: false # https://github.com/marketplace/actions/action-for-semantic-release - id: semantic-release uses: cycjimmy/semantic-release-action@v4 @@ -106,12 +111,12 @@ jobs: branches: | [ "(master|main)", - "v+([0-9])?(.+([0-9]))", + "v+([0-9])?(.{+([0-9]),x}).x", { "name": "next", "prerelease": true }, { "name": "beta", "prerelease": true }, { "name": "alpha", "prerelease": true }, { "name": "staging", "prerelease": "beta" }, - { "name": "develop", "prerelease": "alpha" } + { "name": "(dev|develop|development)", "prerelease": "alpha" } ] env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file