Refactor: ci and code quality (#222) #196
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- master | |
concurrency: | |
group: "publish" | |
cancel-in-progress: true | |
jobs: | |
pub: | |
if: | | |
startsWith(github.event.head_commit.message, 'feat') | |
|| startsWith(github.event.head_commit.message, 'fix') | |
|| startsWith(github.event.head_commit.message, 'bug') | |
|| startsWith(github.event.head_commit.message, 'perf') | |
|| startsWith(github.event.head_commit.message, 'refactor') | |
|| startsWith(github.event.head_commit.message, 'revert') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dart-lang/setup-dart@v1 | |
with: | |
sdk: main | |
- name: Prepare pub credentials | |
run: | | |
mkdir "$XDG_CONFIG_HOME/dart" | |
echo '${{ secrets.PUB_CREDENTIALS }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json" | |
- name: Git config | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Install melos | |
run: | | |
cat pubspec.yaml | |
dart pub global activate melos | |
- name: Uptick versions | |
run: melos sync-version | |
- name: Changelog | |
run: git diff --unified=0 $GITHUB_SHA packages/cli/CHANGELOG.md | tail +6 | sed -e 's/^\+//' > CHANGES.txt | |
- name: Cache Source | |
run: melos cache-source | |
- name: Publish package | |
run: melos publish --no-dry-run --git-tag-version --yes | |
- name: Push tags | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.CONDUIT_PAT }} | |
tags: true | |
branch: master | |
- name: Compute the release tag | |
run: | | |
echo "release_tag=v`cat packages/cli/pubspec.yaml | sed -nre 's/^version: [^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`" >> $GITHUB_ENV | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.release_tag }} | |
body_path: CHANGES.txt | |
docker: | |
if: | | |
startsWith(github.event.head_commit.message, 'feat') | |
|| startsWith(github.event.head_commit.message, 'fix') | |
|| startsWith(github.event.head_commit.message, 'bug') | |
|| startsWith(github.event.head_commit.message, 'perf') | |
|| startsWith(github.event.head_commit.message, 'refactor') | |
|| startsWith(github.event.head_commit.message, 'revert') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Compute the release tag | |
run: | | |
echo "release_tag=v`cat packages/cli/pubspec.yaml | sed -nre 's/^version: [^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
- name: Login | |
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PAT }} | |
- name: Build and Push | |
run: docker buildx build --platform linux/amd64,linux/arm64/v8,linux/arm/v7 --file docker/Dockerfile --tag conduitdart/conduit:${{ env.release_tag }} --push . |