Skip to content

Commit

Permalink
Add pages and oss artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Nov 16, 2022
1 parent eb021a5 commit f2674e9
Show file tree
Hide file tree
Showing 13 changed files with 455 additions and 23 deletions.
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# sln, csproj files (and friends) are always CRLF, even on linux
*.sln text eol=crlf
*.proj text eol=crlf
*.csproj text eol=crlf

# These are windows specific files which we may as well ensure are
# always crlf on checkout
*.bat text eol=crlf
*.cmd text eol=crlf

# Opt in known filetypes to always normalize line endings on checkin
# and always use native endings on checkout
*.c text
*.config text
*.h text
*.cs text
*.md text
*.tt text
*.txt text

# Some must always be checked out as lf so enforce that for those files
# If these are not lf then bash/cygwin on windows will not be able to
# excute the files
*.sh text eol=lf
57 changes: 53 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: build
on:
workflow_dispatch:
push:
branches: [ main, dev, 'feature/*', 'rel/*' ]
branches: [ main, dev, 'dev/*', 'feature/*', 'rel/*' ]
paths-ignore:
- changelog.md
- code-of-conduct.md
Expand All @@ -23,31 +23,80 @@ defaults:
shell: bash

jobs:
os-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.lookup.outputs.matrix }}
steps:
- name: 🤘 checkout
uses: actions/checkout@v2

- name: 🔎 lookup
id: lookup
shell: pwsh
run: |
$path = './.github/workflows/os-matrix.json'
$os = if (test-path $path) { cat $path } else { '["ubuntu-latest"]' }
echo "matrix=$os" >> $env:GITHUB_OUTPUT
build:
runs-on: windows-latest
needs: os-matrix
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJSON(needs.os-matrix.outputs.matrix) }}
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v1
if: matrix.os != 'windows-latest'
with:
dotnet-version: '6.0.x'

- name: 🙏 build
run: dotnet build -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"

- name: ⚙ GNU grep
if: matrix.os == 'macOS-latest'
run: |
brew install grep
echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> .bash_profile
- name: 🧪 test
uses: ./.github/workflows/test

- name: 📦 pack
run: dotnet pack -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"

# Only push CI package to sleet feed if building on ubuntu (fastest)
- name: 🚀 sleet
env:
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
if: env.SLEET_CONNECTION != ''
if: matrix.os == 'ubuntu-latest' && env.SLEET_CONNECTION != ''
run: |
dotnet tool install -g --version 4.0.18 sleet
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"
dotnet-format:
runs-on: ubuntu-latest
needs: build
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: ✓ ensure format
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget
run: dotnet format --verify-no-changes -v:diag --exclude ~/.nuget
9 changes: 9 additions & 0 deletions .github/workflows/changelog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
usernames-as-github-logins=true
issues_wo_labels=true
pr_wo_labels=true
exclude-labels=bydesign,dependencies,duplicate,question,invalid,wontfix,need info
enhancement-label=:sparkles: Implemented enhancements:
bugs-label=:bug: Fixed bugs:
issues-label=:hammer: Other:
pr-label=:twisted_rightwards_arrows: Merged:
unreleased=false
154 changes: 154 additions & 0 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: '⛙ combine-prs'

on:
workflow_dispatch:
inputs:
branchExpression:
description: 'Regular expression to match against PR branches to find combinable PRs'
required: true
default: 'dependabot'
mustBeGreen:
description: 'Only combine PRs that are green (status is success)'
required: true
default: true
combineTitle:
description: 'Title of the combined PR'
required: true
default: '⬆️ Bump dependencies'
combineBranchName:
description: 'Name of the branch to combine PRs into'
required: true
default: 'combine-prs'
ignoreLabel:
description: 'Exclude PRs with this label'
required: true
default: 'nocombine'

jobs:
combine-prs:
name: ${{ github.event.inputs.combineBranchName }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
owner: context.repo.owner,
repo: context.repo.repo
});
const branchRegExp = new RegExp(`${{github.event.inputs.branchExpression}}`);
let branchesAndPRStrings = [];
let baseBranch = null;
let baseBranchSHA = null;
for (const pull of pulls) {
const branch = pull['head']['ref'];
console.log('Pull for branch: ' + branch);
if (branchRegExp.test(branch)) {
console.log('Branch matched prefix: ' + branch);
let statusOK = true;
if(${{ github.event.inputs.mustBeGreen }}) {
console.log('Checking green status: ' + branch);
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number:$pull_number) {
commits(last: 1) {
nodes {
commit {
statusCheckRollup {
state
}
}
}
}
}
}
}`
const vars = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull['number']
};
const result = await github.graphql(stateQuery, vars);
const [{ commit }] = result.repository.pullRequest.commits.nodes;
const state = commit.statusCheckRollup.state
console.log('Validating status: ' + state);
if(state != 'SUCCESS') {
console.log('Discarding ' + branch + ' with status ' + state);
statusOK = false;
}
}
console.log('Checking labels: ' + branch);
const labels = pull['labels'];
for(const label of labels) {
const labelName = label['name'];
console.log('Checking label: ' + labelName);
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
console.log('Discarding ' + branch + ' with label ' + labelName);
statusOK = false;
}
}
if (statusOK) {
console.log('Adding branch to array: ' + branch);
const prString = '#' + pull['number'] + ' ' + pull['title'];
branchesAndPRStrings.push({ branch, prString });
baseBranch = pull['base']['ref'];
baseBranchSHA = pull['base']['sha'];
}
}
}
if (branchesAndPRStrings.length == 0) {
core.setFailed('No PRs/branches matched criteria');
return;
}
if (branchesAndPRStrings.length == 1) {
core.setFailed('Only one PR/branch matched criteria');
return;
}
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/heads/' + '${{ github.event.inputs.combineBranchName }}',
sha: baseBranchSHA
});
} catch (error) {
console.log(error);
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
return;
}
let combinedPRs = [];
let mergeFailedPRs = [];
for(const { branch, prString } of branchesAndPRStrings) {
try {
await github.rest.repos.merge({
owner: context.repo.owner,
repo: context.repo.repo,
base: '${{ github.event.inputs.combineBranchName }}',
head: branch,
});
console.log('Merged branch ' + branch);
combinedPRs.push(prString);
} catch (error) {
console.log('Failed to merge branch ' + branch);
mergeFailedPRs.push(prString);
}
}
console.log('Creating combined PR');
const combinedPRsString = combinedPRs.join('\n');
let body = '⛙ Combined PRs:\n' + combinedPRsString;
if(mergeFailedPRs.length > 0) {
const mergeFailedPRsString = mergeFailedPRs.join('\n');
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString
}
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '⛙ ${{github.event.inputs.combineTitle}}',
head: '${{ github.event.inputs.combineBranchName }}',
base: baseBranch,
body: body
});
43 changes: 43 additions & 0 deletions .github/workflows/includes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: +Mᐁ includes
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- '**.md'
- '!changelog.md'

jobs:
includes:
runs-on: ubuntu-latest
steps:
- name: 🤖 defaults
uses: devlooped/actions-bot@v1
with:
name: ${{ secrets.BOT_NAME }}
email: ${{ secrets.BOT_EMAIL }}
gh_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: 🤘 checkout
uses: actions/checkout@v2
with:
token: ${{ env.GH_TOKEN }}

- name: +Mᐁ includes
uses: devlooped/actions-include@v1

- name: ✍ pull request
uses: peter-evans/create-pull-request@v3
with:
base: main
branch: markdown-includes
delete-branch: true
labels: docs
author: ${{ env.BOT_AUTHOR }}
committer: ${{ env.BOT_AUTHOR }}
commit-message: +Mᐁ includes
title: +Mᐁ includes
body: +Mᐁ includes
token: ${{ env.GH_TOKEN }}
13 changes: 7 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ env:
DOTNET_NOLOGO: true
Configuration: Release

defaults:
run:
shell: bash

jobs:
publish:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: 🙏 build
run: dotnet build -m:1 -p:version=${GITHUB_REF#refs/*/v}

Expand All @@ -35,4 +36,4 @@ jobs:
run: dotnet pack -m:1 -p:version=${GITHUB_REF#refs/*/v}

- name: 🚀 nuget
run: dotnet nuget push ./bin/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
run: dotnet nuget push ./bin/**/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
24 changes: 24 additions & 0 deletions .github/workflows/sponsor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: sponsor 💜
on:
issues:
types: [opened, edited, reopened]
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
sponsor:
runs-on: ubuntu-latest
continue-on-error: true
env:
token: ${{ secrets.GH_TOKEN }}
if: ${{ !endsWith(github.event.sender.login, '[bot]') && !endsWith(github.event.sender.login, 'bot') }}
steps:
- name: 🤘 checkout
if: env.token != ''
uses: actions/checkout@v2

- name: 💜 sponsor
if: env.token != ''
uses: devlooped/actions-sponsor@main
with:
token: ${{ env.token }}
Loading

0 comments on commit f2674e9

Please sign in to comment.