Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

als-branch #944

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
45 changes: 45 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Issue Report
about: Report a bug, suggest an enhancement, or ask a question
title: ""
labels: ""
assignees: ""
---

## Issue Type

Please inform the type(s) of issue(s) you are reporting:

- Bug Report
- Feature Request
- Discussion
- Question

## Description

Please provide a clear and concise description of the issue or enhancement.
Include any relevant information that could help reproduce the issue or
understand the request.

## Steps to Reproduce (for bugs)

1. Step one
2. Step two
3. ...

## Expected Behavior

Describe what you expected to happen.

## Actual Behavior

Describe what actually happened.

## Additional Context

Add any other context about the issue here, including screenshots, logs, or
other supporting information.

---

Thank you for taking the time to report this issue!
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- deno-fmt-ignore-file -->
## What is this Contribution About?

Please provide a brief description of the changes or enhancements you are proposing in this pull request.

## Issue Link

Please link to the relevant issue that this pull request addresses:

- Issue: [#ISSUE_NUMBER](link_to_issue)

## Loom Video

> Record a quick screencast describing your changes to help the team understand and review your contribution. This will greatly assist in the review process.

## Demonstration Link

> Provide a link to a branch or environment where this pull request can be tested and seen in action.
20 changes: 20 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🚨
labels:
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- title: Preview features 🍪
labels:
- preview-feature
- title: Bugs fixed 🐛
labels:
- bug
- title: Other Changes
labels:
- "*"
54 changes: 54 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: ci

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
name: "Bundle & Check Apps"
steps:
- uses: actions/checkout@v3
- name: cache deno installation and deno.land dependencies
uses: actions/cache@v2
with:
key: ${{ runner.os }}-deno-${{ hashFiles('**/*') }}
restore-keys: ${{ runner.os }}-deno-
path: |
/home/runner/.deno
/home/runner/.cache/deno/deps/https/deno.land
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Bundle Apps
run: deno run -A --lock=deno.lock --lock-write --reload scripts/start.ts

- name: Check
run: deno task check

- name: Check if there are changes on ${{ matrix.os }}
id: changes
shell: bash
run: |
git status --porcelain
if [[ $(git status --porcelain | wc -c) -eq 0 ]]; then
echo "uncommitted changes detected"
exit 1
fi

- name: Test
continue-on-error: true
run: deno test --lock=deno.lock --lock-write -A .

- name: Benchmark
continue-on-error: true
run: deno bench --lock=deno.lock --lock-write -A .
18 changes: 18 additions & 0 deletions .github/workflows/issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Label issues
on:
issues:
types:
- reopened
- opened
jobs:
label_issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: triage
45 changes: 45 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# https://docs.github.com/en/actions

name: "Release"

on: # yamllint disable-line rule:truthy
push:
tags:
- "**"
workflow_dispatch: # Allows manual dispatch with parameters
inputs:
tag_name:
description: "The tag to be published"
required: true
permissions: write-all
jobs:
release:
permissions: write-all
name: "Release"
runs-on: "ubuntu-latest"

steps:
- name: "Create release"
env:
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.ref_name }}
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const tag = process.env.RELEASE_TAG;
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: `Release ${tag}`,
owner: context.repo.owner,
prerelease: tag.includes("rc-") || tag.includes("preview") || tag.includes("beta") || tag.includes("alpha"),
repo: context.repo.repo,
tag_name: tag,
});

core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
172 changes: 172 additions & 0 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Release Tagging

on:
pull_request_target:
types: [opened]

push:
branches:
- main

permissions:
contents: write # Necessary for accessing and modifying repository content
pull-requests: write # Necessary for interacting with pull requests
actions: write # Necessary for triggering other workflows

jobs:
tag-discussion:
if: github.event_name == 'pull_request_target' && github.event.action == 'opened'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }} # Checkout the base branch (target repository)
repository: ${{ github.event.pull_request.base.repo.full_name }} # Checkout from the target repo

- name: Calculate new versions
id: calculate_versions
run: |
git fetch --tags
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="0.0.0"
fi
MAJOR=$(echo $LATEST_TAG | cut -d. -f1)
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
PATCH=$(echo $LATEST_TAG | cut -d. -f3)
NEW_PATCH_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
NEW_MINOR_VERSION="$MAJOR.$((MINOR + 1)).0"
NEW_MAJOR_VERSION="$((MAJOR + 1)).0.0"
echo "patch_version=$NEW_PATCH_VERSION" >> $GITHUB_OUTPUT
echo "minor_version=$NEW_MINOR_VERSION" >> $GITHUB_OUTPUT
echo "major_version=$NEW_MAJOR_VERSION" >> $GITHUB_OUTPUT

- name: Start Discussion for Tagging
uses: peter-evans/create-or-update-comment@v2
id: comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Tagging Options
Should a new tag be published when this PR is merged?
- 👍 for **Patch** ${{ steps.calculate_versions.outputs.patch_version }} update
- 🎉 for **Minor** ${{ steps.calculate_versions.outputs.minor_version }} update
- 🚀 for **Major** ${{ steps.calculate_versions.outputs.major_version }} update

determine-tag:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Find the Merged Pull Request
id: find_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BASE_BRANCH="main"
RECENT_PR=$(gh pr list --state closed --base $BASE_BRANCH --json number,title,closedAt --jq '.[] | select(.closedAt >= "'$(date -u -d '1 minute ago' +%Y-%m-%dT%H:%M:%SZ)'") | {number, title}')
echo "RECENT_PR=$RECENT_PR" >> $GITHUB_ENV
echo "PR_NUMBER=$(echo $RECENT_PR | jq -r '.number')" >> $GITHUB_ENV

- name: Fetch latest stable tag (excluding prerelease tags)
id: get_latest_tag
run: |
git fetch --tags
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="0.0.0"
fi
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT

- name: Determine the next version based on comments
id: determine_version
if: env.PR_NUMBER != ''
env:
PR_NUMBER: ${{ env.PR_NUMBER }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LATEST_TAG=${{ steps.get_latest_tag.outputs.latest_tag }}
MAJOR=$(echo $LATEST_TAG | cut -d. -f1)
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
PATCH=$(echo $LATEST_TAG | cut -d. -f3)

# Define allowed users as a JSON array
ALLOWED_USERS=$(cat MAINTAINERS.txt | jq -R -s -c 'split("\n")[:-1]')
echo "Maintainers list: $ALLOWED_USERS"

# Fetch reactions and filter by allowed users
REACTION=$(gh api graphql -f query='
query {
repository(owner:"${{ github.repository_owner }}", name:"${{ github.event.repository.name }}") {
pullRequest(number: '${PR_NUMBER}') {
comments(last: 100) {
nodes {
body
id
reactions(last: 100) {
nodes {
content
user {
login
}
}
}
}
}
}
}
}' | jq -r --argjson allowed_users "$ALLOWED_USERS" '
.data.repository.pullRequest.comments.nodes[] |
select(.body | contains("## Tagging Options")) |
.reactions.nodes[] |
select(.user.login | IN($allowed_users[])) |
.content'
)
# Print the reaction to debug
echo "Captured reaction: $REACTION"

# Convert reaction to uppercase to handle any case inconsistencies
REACTION=$(echo "$REACTION" | tr '[:lower:]' '[:upper:]')

# Determine the new tag version based on the allowed reactions
if [[ "$REACTION" == *"ROCKET"* ]]; then
NEW_TAG="$((MAJOR + 1)).0.0"
elif [[ "$REACTION" == *"HOORAY"* ]]; then
NEW_TAG="$MAJOR.$((MINOR + 1)).0"
elif [[ "$REACTION" == *"THUMBS_UP"* ]]; then # Ensure thumbs up reaction is correctly identified
NEW_TAG="$MAJOR.$MINOR.$((PATCH + 1))"
else
echo "No valid reactions found for version bump. Exiting."
exit 0
fi


echo "new_version=$NEW_TAG" >> $GITHUB_OUTPUT

- name: Update deno.json Version
if: steps.determine_version.outputs.new_version != ''
run: |
jq --arg new_version "${{ steps.determine_version.outputs.new_version }}" '.version = $new_version' deno.json > tmp.$$.json && mv tmp.$$.json deno.json
git config user.name "decobot"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add deno.json
git commit -m "Update version to ${{ steps.determine_version.outputs.new_version }}"
git push origin main

- name: Create and Push Tag
if: steps.determine_version.outputs.new_version != ''
run: |
git tag ${{ steps.determine_version.outputs.new_version }}
git push origin ${{ steps.determine_version.outputs.new_version }}

- name: Trigger Release Workflow
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/release.yaml/dispatches \
-d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}'
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true
}
}
Loading
Loading