Skip to content

Commit

Permalink
Create CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Dec 1, 2023
1 parent 894b1b9 commit 8d52262
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @0xbe7a @pavelzw
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
registries:
github:
type: git
url: https://github.com
username: x-access-token
password: ${{ secrets.DEPENDABOT_CONTENT_PAT }}
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
reviewers:
- quantco/ci
registries:
- github
groups:
dependencies:
patterns:
- "*"
- package-ecosystem: github-actions
directory: /template/.github/workflows
schedule:
interval: daily
reviewers:
- quantco/ci
registries:
- github
groups:
dependencies:
patterns:
- "*"
40 changes: 40 additions & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

version="${TAG_NAME}"
major="${version%%.*}" # see https://linuxjournal.com/article/8919 for an explanation of this bash magic

git tag -d "${major}"
local_delete=$?
if [ $local_delete -eq 0 ]; then
echo "Deleted local tag ${major}."
echo "Deleted local tag \`${major}\`." >> "$GITHUB_STEP_SUMMARY"
else
echo "No local tag ${major} to delete."
echo "No local tag \`${major}\` to delete." >> "$GITHUB_STEP_SUMMARY"
fi
git tag "${major}"

git push -d origin "${major}"
remote_delete=$?
if [ $remote_delete -eq 0 ]; then
echo "Deleted remote tag ${major}."
echo "Deleted remote tag \`${major}\`." >> "$GITHUB_STEP_SUMMARY"
else
echo "No remote tag ${major} to delete."
echo "No remote tag \`${major}\` to delete." >> "$GITHUB_STEP_SUMMARY"
fi
git push origin "${major}"
push_worked=$?
if [ $push_worked -ne 0 ]; then
echo "Failed to push ${major} tag to remote."
echo "Failed to push \`${major}\` tag to remote." >> "$GITHUB_STEP_SUMMARY"
exit 1
fi

if [ $remote_delete -eq 0 ]; then
echo "Result: moved ${major} -> ${version} tag on remote."
echo "Result: moved \`${major}\` -> \`${version}\` tag on remote." >> "$GITHUB_STEP_SUMMARY"
else
echo "Result: created ${major} -> ${version} tag on remote."
echo "Result: created \`${major}\` -> \`${version}\` tag on remote." >> "$GITHUB_STEP_SUMMARY"
fi
40 changes: 40 additions & 0 deletions .github/workflows/bump-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Bump versions
on:
workflow_dispatch:
schedule:
- cron: "0 6 * * MON"

jobs:
bump:
strategy:
fail-fast: false
matrix:
include:
- { tool: mamba-org/setup-micromamba }
- { tool: actions/cache }
name: Bump ${{ matrix.tool }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump versions
id: bump
run: |
set -euo pipefail
new_version="$(gh repo view --json latestRelease ${{ matrix.tool }} | jq -r '.latestRelease.tagName')"
echo "new-version=$new_version" >> "$GITHUB_OUTPUT"
commit_sha="$(gh api "repos/${{ matrix.tool }}/commits/$new_version" | jq -r '.sha')"
current_sha="$(grep "${{ matrix.tool }}@" action.yml | awk -F@ '{print $2}')"
if [[ "$commit_sha" != "$current_sha" ]]; then
sed -i "s/${{ matrix.tool }}@${current_sha}/${{ matrix.tool }}@${commit_sha}/g" action.yml
else
echo "${{ matrix.tool }} is already at the latest version: $current_sha"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
title: Bump ${{ matrix.tool }} to ${{ steps.bump.outputs.new-version }}
delete-branch: true
commit-message: Bump ${{ matrix.tool }} version to ${{ steps.bump.outputs.new-version }}
branch: bump-${{ matrix.tool }}-${{ steps.bump.outputs.new-version }}
21 changes: 21 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
push:
tags:
# only release von 'vx.y.z' tags, not on the 'vx' tag itself
- 'v*.*.*'
permissions:
contents: write

# To release a new version, create a release called `v*.*.*` from the GitHub UI.
# This will create a draft release with the changelog and push a 'vx' tag that points to the new release.

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: .github/scripts/release.sh
env:
TAG_NAME: ${{ github.ref_name }}

0 comments on commit 8d52262

Please sign in to comment.