Skip to content

Commit

Permalink
ci: automate releases with release-please (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
jthegedus authored Mar 9, 2023
1 parent 46f217a commit e775639
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 193 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build

on:
push:
branches:
- master
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- name: Retrieve yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: v1-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
v1-${{ runner.os }}-yarn-
- name: Install npm packages
run: yarn --frozen-lockfile

- name: Ensure out directories are up-to-date
if: runner.os == 'Linux'
shell: bash
run: |
yarn build
if [ "$(git status --porcelain | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CodeQL
name: codeql

on:
- pull_request
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: lint

on:
push:
branches:
- master
pull_request:

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- name: Install npm packages
run: yarn --frozen-lockfile
- name: Check lint
run: yarn lint

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- name: Install npm packages
run: yarn --frozen-lockfile
- name: Check formatting
run: yarn fmt:check

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- name: Install npm packages
run: yarn --frozen-lockfile
- name: Check types
run: yarn typecheck

actionlint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Check workflow files
uses: docker://rhysd/actionlint:1.6.23
with:
args: -color
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: release

on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
command: github-release
# extra-files: |
# README.md
- uses: actions/checkout@v2
- name: tag major versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }} || true
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
git push origin v${{ steps.release.outputs.major }}
18 changes: 18 additions & 0 deletions .github/workflows/semantic-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: lint

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
semantic-pr:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true
98 changes: 98 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: test

on:
push:
branches:
- master
pull_request:

jobs:
asdf_is_installed:
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: setup asdf
uses: ./setup
- name: asdf is available
run: |
echo ASDF_DIR="${ASDF_DIR}"
echo ASDF_DATA_DIR="${ASDF_DATA_DIR}"
echo PATH="${PATH}"
asdf --version
plugin_is_tested:
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./plugin-test
with:
command: direnv --version
plugin: direnv
giturl: https://github.com/asdf-community/asdf-direnv.git
gitref: master

plugins_are_installed:
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./plugins-add
with:
tool_versions: |
# tools won't be installed by this action, only plugins
elixir foo
nodejs bar
- run: |
asdf plugin list --urls --refs | grep elixir
asdf plugin list --urls --refs | grep nodejs
installing-plugins-already-installed-are-skiped:
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./setup
- name: Add an asdf plugin
run: |
asdf plugin-add clusterctl https://github.com/pfnet-research/asdf-clusterctl.git
- uses: ./plugins-add
with:
tool_versions: |
# tools won't be installed by this action, only plugins
elixir foo
nodejs bar
# plugins already installed are here
clusterctl tako
- run: |
asdf plugin list --urls --refs | grep elixir
asdf plugin list --urls --refs | grep nodejs
asdf plugin list --urls --refs | grep clusterctl
tools_are_installed:
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: setup asdf
uses: ./install
with:
before_install: echo asdf nodejs import-keyring
tool_versions: direnv 2.32.1
- run: direnv version
Loading

0 comments on commit e775639

Please sign in to comment.