From 90ec26e592b043fd29a96814395f503a0e3165a3 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Wed, 22 Jan 2025 16:43:14 -0500 Subject: [PATCH] feat: split CI and Release, prerelease from rc/* branches NB. Using "feat:" in the message to trigger version changes. --- .github/workflows/ci.yml | 104 ++------------------------------ .github/workflows/release.yml | 109 ++++++++++++++++++++++++++++++++++ install | 2 +- justfile | 36 +++-------- 4 files changed, 124 insertions(+), 127 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d056a468..91e476f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,6 @@ name: CI on: pull_request: - push: - branches: main concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -11,16 +9,7 @@ concurrency: jobs: build: - strategy: - matrix: - os: [linux] - - include: - - os: linux - runner: ubuntu-latest - - runs-on: ${{ matrix.runner }} - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - id: stack @@ -28,14 +17,11 @@ jobs: - uses: freckle/weeder-action@v2 with: ghc-version: ${{ steps.stack.outputs.compiler-version }} - - run: | - dist=restyler-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) - mkdir -p "$dist" - cp -v ${{ steps.stack.outputs.local-install-root }}/bin/* "$dist" - tar czf "$dist.tar.gz" "$dist" + - uses: extractions/setup-just@v2 + - run: just dist - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-binaries + name: binaries path: "restyler-*.tar.gz" if-no-files-found: error @@ -49,7 +35,6 @@ jobs: fail-on: warning commitlint: - if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -68,14 +53,13 @@ jobs: BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} - integration-test: - if: ${{ github.event_name == 'pull_request' }} + test-integration: runs-on: ubuntu-latest needs: [build] steps: - uses: actions/download-artifact@v4 with: - name: linux-binaries + name: binaries - run: | tar xzf restyler-*.tar.gz mkdir -p ./bin @@ -89,84 +73,8 @@ jobs: paths: . log-level: debug - release: - runs-on: ubuntu-latest - needs: [build] - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - - - id: token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.AUTOMATION_APP_ID }} - private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} - - - id: release - uses: cycjimmy/semantic-release-action@v4 - env: - GITHUB_TOKEN: ${{ steps.token.outputs.token }} - - - if: ${{ steps.release.outputs.new_release_published == 'true' }} - run: | - gh release upload "$TAG" ./*-binaries/restyler-*.tar.gz - env: - TAG: ${{ steps.release.outputs.new_release_git_tag }} - GH_TOKEN: ${{ github.token }} - - docs: - #if: ${{ github.ref == 'refs/heads/main' }} - needs: [build] - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - contents: read - pages: write - id-token: write - runs-on: ubuntu-latest - steps: - - run: gem install --user ronn-ng - - run: | - for bin in ~/.local/share/gem/ruby/*/bin; do - echo "$bin" - done >>"$GITHUB_PATH" - - - uses: actions/download-artifact@v4 - with: - name: linux-binaries - - run: | - tar xzf restyler-*.tar.gz - mkdir -p ./bin - sudo mv -v restyler-*/restyle /usr/local/bin - - # TODO: only checkout doc folder - - uses: actions/checkout@v4 - - - name: Generate ronn documenation - run: | - restyle __render-docs-man1__ > doc/restyle.1.ronn - restyle __render-docs-man5__ > doc/restyled.yaml.5.ronn - - - name: Generate HTML sources to _site - run: | - env \ - RONN_STYLE=./doc \ - RONN_ORGANIZATION=Restyled \ - RONN_MANUAL="Restyler v$(restyle --version | cut -d' ' -f 2)" \ - ronn --style toc,custom --roff --html doc/*.ronn - - mkdir -p _site/man-pages - cp -v doc/*.html _site/man-pages/ - - - uses: actions/upload-pages-artifact@v3 - with: - path: _site - - id: deployment - uses: actions/deploy-pages@v4 test-install: - if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..3eb9aa5d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,109 @@ +name: Release + +on: + push: + branches: + - main + - rc/* + +jobs: + build: + strategy: + matrix: + os: [linux] + + include: + - os: linux + runner: ubuntu-latest + + runs-on: ${{ matrix.runner }} + + steps: + - uses: actions/checkout@v4 + - id: stack + uses: freckle/stack-action@v5 + - uses: freckle/weeder-action@v2 + with: + ghc-version: ${{ steps.stack.outputs.compiler-version }} + - uses: extractions/setup-just@v2 + - run: just dist + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-binaries + path: "restyler-*.tar.gz" + if-no-files-found: error + + release: + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + + - id: token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.AUTOMATION_APP_ID }} + private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} + + - id: release + uses: cycjimmy/semantic-release-action@v4 + env: + GITHUB_TOKEN: ${{ steps.token.outputs.token }} + + - if: ${{ steps.release.outputs.new_release_published == 'true' }} + run: | + gh release upload "$TAG" ./*-binaries/restyler-*.tar.gz + env: + TAG: ${{ steps.release.outputs.new_release_git_tag }} + GH_TOKEN: ${{ github.token }} + + docs: + needs: [build] + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + contents: read + pages: write + id-token: write + runs-on: ubuntu-latest + steps: + - run: gem install --user ronn-ng + - run: | + for bin in ~/.local/share/gem/ruby/*/bin; do + echo "$bin" + done >>"$GITHUB_PATH" + + - uses: actions/download-artifact@v4 + with: + name: linux-binaries + - run: | + tar xzf restyler-*.tar.gz + mkdir -p ./bin + sudo mv -v restyler-*/restyle /usr/local/bin + + # TODO: only checkout doc folder + - uses: actions/checkout@v4 + + - name: Generate ronn documenation + run: | + restyle __render-docs-man1__ > doc/restyle.1.ronn + restyle __render-docs-man5__ > doc/restyled.yaml.5.ronn + + - name: Generate HTML sources to _site + run: | + env \ + RONN_STYLE=./doc \ + RONN_ORGANIZATION=Restyled \ + RONN_MANUAL="Restyler v$(restyle --version | cut -d' ' -f 2)" \ + ronn --style toc,custom --roff --html doc/*.ronn + + mkdir -p _site/man-pages + cp -v doc/*.html _site/man-pages/ + + - uses: actions/upload-pages-artifact@v3 + with: + path: _site + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/install b/install index 5ee1c902..51702de7 100755 --- a/install +++ b/install @@ -52,7 +52,7 @@ if [ -z "$tag" ]; then -sSf https://api.github.com/repos/restyled-io/restyler/releases | grep -o '"tag_name": ".*"' | sed 's/^.*: "//; s/"$//' | - grep -v -- '-rc$' | + grep -v -- '-rc-.*$' | head -n 1) fi diff --git a/justfile b/justfile index 4d14f9f4..aee0c986 100644 --- a/justfile +++ b/justfile @@ -35,31 +35,11 @@ headroom: stack exec -- headroom run stack exec -- fourmolu -i app src test -# aws := "aws --profile restyled-ci" - -# doc_bucket := ` -# {{aws}} cloudformation describe-stacks \ -# --stack-name sites-docs \ -# --query 'Stacks[*].Outputs[?OutputKey==`BucketName`].OutputValue' \ -# --output text \ -# ` - -# doc_distribution_id := ` -# {{aws}} cloudformation describe-stacks \ -# --stack-name sites-docs \ -# --query 'Stacks[*].Outputs[?OutputKey==`DistributionId`].OutputValue' \ -# --output text \ -# ` - -# doc_root := `stack path --local-doc-root` -# doc_s3_prefix := /restyler - -# docs: -# [ -n "$$STACK_WORK_DIR" ] -# stack build --haddock -# find "$$STACK_WORK_DIR" -type f -name '*.html' -exec \ -# sed -i 's|{{doc_root}}|{{doc_s3_prefix}}|g' {} + -# {{aws}} s3 sync --acl public-read --delete {{doc_root}}/ \ -# s3://{{doc_bucket}}{{doc_s3_prefix}}/ -# {{aws}} cloudfront create-invalidation \ -# --distribution-id {{doc_distribution_id}} --paths "{{doc_s3_prefix}}/*" +install-root := `stack path --local-install-root` +dist := 'restyler-' + `uname -s | tr '[:upper:]' '[:lower:]'` + '-' + `uname -m` +ext := 'tar.gz' + +dist: + mkdir -p '{{dist}}' + cp -v '{{install-root}}'/bin/* '{{dist}}' + tar czf '{{dist}}.{{ext}}' '{{dist}}'