From e16ba65389f50d35d70709bb6fcc601e25c9e8ee Mon Sep 17 00:00:00 2001 From: Bryan Richter Date: Tue, 16 Jun 2026 11:55:19 +0300 Subject: [PATCH] Use shared workflows from p4lang/.github Signed-off-by: Bryan Richter --- .github/workflows/ci-auto-release.yml | 115 -------------------------- .github/workflows/ci-release.yml | 58 ------------- .github/workflows/monthly-release.yml | 23 ++++++ .github/workflows/publish-release.yml | 28 +++++++ 4 files changed, 51 insertions(+), 173 deletions(-) delete mode 100644 .github/workflows/ci-auto-release.yml delete mode 100644 .github/workflows/ci-release.yml create mode 100644 .github/workflows/monthly-release.yml create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/ci-auto-release.yml b/.github/workflows/ci-auto-release.yml deleted file mode 100644 index d0249b1a2..000000000 --- a/.github/workflows/ci-auto-release.yml +++ /dev/null @@ -1,115 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Anamika Aggarwal -# -# SPDX-License-Identifier: Apache-2.0 - -name: Automated Release - -on: - workflow_dispatch: - schedule: - - cron: "17 12 1 * *" # At 12:17 on day-of-month 1 (avoid top-of-hour load) - -permissions: - contents: write - pull-requests: write - -jobs: - build: - runs-on: ubuntu-latest - # Check if the event is not triggered by a fork - if: ${{ github.repository == 'p4lang/behavioral-model' && github.ref == 'refs/heads/main' }} - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - # Fetch all history for all branches and tags - fetch-depth: 0 - - - name: Check for new commits - id: check_commits - run: | - TAG="$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)" - COMMIT_COUNT="$(git rev-list $TAG..HEAD --count)" - echo "count=$COMMIT_COUNT" >> $GITHUB_OUTPUT - if [ "$COMMIT_COUNT" -eq 0 ]; then - echo "No new commits since $TAG, skipping release." - else - echo "$COMMIT_COUNT new commits since $TAG." - fi - - - name: Increment version number - if: steps.check_commits.outputs.count != '0' - run: perl -i -pe 's/\b(\d+)(?=\D*$)/$1+1/e' VERSION - - - name: Get changelog - if: steps.check_commits.outputs.count != '0' - id: changelog - run: | - TAG="$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)" - GIT_LOG="$(git log $TAG..HEAD --oneline --pretty=format:"- %s [%an]")" - CHANGELOG=$(cat << EOF - Changelog: - $GIT_LOG - EOF - ) - CHANGELOG="${CHANGELOG//'#'/''}" - echo "content<> "$GITHUB_OUTPUT" - echo "$CHANGELOG" >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - - name: Display changelog - if: steps.check_commits.outputs.count != '0' - run: | - cat <<'EOF' - ${{ steps.changelog.outputs.content }} - EOF - - - name: Get version - if: steps.check_commits.outputs.count != '0' - run: | - VERSION="$(cat VERSION)" - echo "VERSION=$VERSION" >> $GITHUB_ENV - - - name: Get commit message - if: steps.check_commits.outputs.count != '0' - id: message - run: | - COMMIT_MSG=$(cat << 'EOF' - Release ${{ env.VERSION }} - - ${{ steps.changelog.outputs.content }} - EOF - ) - echo "content<> "$GITHUB_OUTPUT" - echo "$COMMIT_MSG" >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - - name: Get pull request body message - if: steps.check_commits.outputs.count != '0' - id: body - run: | - MSG=$(cat << 'EOF' - Auto-generated pull request for version ${{ env.VERSION }}. - - Please use **Squash and merge** to include the changelog in the release message. - - ${{ steps.changelog.outputs.content }} - EOF - ) - echo "content<> "$GITHUB_OUTPUT" - echo "$MSG" >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - - name: Create Pull Request - if: steps.check_commits.outputs.count != '0' - uses: peter-evans/create-pull-request@v8 - with: - base: main - add-paths: VERSION - reviewers: fruffy, jafingerhut - commit-message: ${{ steps.message.outputs.content }} - signoff: true - branch: release/${{ env.VERSION }} - delete-branch: true - title: Automated Release ${{ env.VERSION }} - body: ${{ steps.body.outputs.content }} diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml deleted file mode 100644 index 20cc2da9c..000000000 --- a/.github/workflows/ci-release.yml +++ /dev/null @@ -1,58 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Anamika Aggarwal -# -# SPDX-License-Identifier: Apache-2.0 - -name: GitHub Release - -on: - push: - branches: - - main - paths: - - "VERSION" - - ".github/workflows/ci-release.yml" - -# Cancel any preceding run on the pull request. -concurrency: - group: release-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - build: - if: ${{ github.repository == 'p4lang/behavioral-model' }} - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Get version - run: | - VERSION="$(cat VERSION)" - TAG="$(cat VERSION)" - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "TAG=$TAG" >> $GITHUB_ENV - - - name: Check if tag exists - id: check_tag - run: | - TAG="${{ env.TAG }}" - if git rev-parse "$TAG" >/dev/null 2>&1; then - echo "Tag $TAG already exists, skipping release creation." - echo "tag_exists=true" >> $GITHUB_OUTPUT - else - echo "Tag $TAG does not exist." - echo "tag_exists=false" >> $GITHUB_OUTPUT - fi - - - name: Release - if: steps.check_tag.outputs.tag_exists == 'false' - uses: softprops/action-gh-release@v3 - with: - tag_name: ${{ env.TAG }} - generate_release_notes: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/monthly-release.yml b/.github/workflows/monthly-release.yml new file mode 100644 index 000000000..ad64b750f --- /dev/null +++ b/.github/workflows/monthly-release.yml @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2026 The P4 Language Consortium +# +# SPDX-License-Identifier: Apache-2.0 + +name: Monthly Release + +on: + workflow_dispatch: + schedule: + - cron: "17 12 1 * *" # At 12:17 on day-of-month 1 (avoid top-of-hour load) + +permissions: + contents: write + pull-requests: write + +jobs: + monthly-release: + if: ${{ github.repository == 'p4lang/behavioral-model' }} + uses: p4lang/.github/.github/workflows/bump-version.yml@main + with: + tag_prefix: "" + branch_pattern: "release/{version}" + reviewers: fruffy, jafingerhut diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 000000000..77e7f66d6 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2026 The P4 Language Consortium +# +# SPDX-License-Identifier: Apache-2.0 + +name: Publish Release + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "VERSION" + +permissions: + contents: write + +# Cancel any preceding run on the pull request. +concurrency: + group: release-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + publish-release: + if: ${{ github.repository == 'p4lang/behavioral-model' }} + uses: p4lang/.github/.github/workflows/publish-release.yml@main + with: + tag_prefix: ""