diff --git a/.github/workflows/cd.installer.yml b/.github/workflows/cd.installer.yml index 2b9b433..ae46cb0 100644 --- a/.github/workflows/cd.installer.yml +++ b/.github/workflows/cd.installer.yml @@ -1,3 +1,5 @@ +name: cd·installer + on: pull_request: paths: @@ -10,6 +12,7 @@ on: jobs: cd: + if: github.repository == 'pkgxdev/mash' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -25,3 +28,10 @@ jobs: - run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths / /installer.sh + + test: + needs: cd + runs-on: ubuntu-latest + steps: + - run: curl -L mash.pkgx.sh | sh + - run: mash demo test-pattern diff --git a/.github/workflows/cd.www.yml b/.github/workflows/cd.www.yml new file mode 100644 index 0000000..799cefd --- /dev/null +++ b/.github/workflows/cd.www.yml @@ -0,0 +1,66 @@ +name: cd·www + +on: + push: + branches: main + paths: + - .github/workflows/deploy.yml + - .github/scripts/* + - scripts/* + pull_request: + paths: + - .github/workflows/deploy.yml + schedule: + - cron: '23 * * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + if: github.repository == 'pkgxdev/mash' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pkgxdev/setup@v3 + + - name: trawl + run: .github/scripts/trawl.ts --out ./build + env: + GH_TOKEN: ${{ github.token }} + + - name: index + run: | + mkdir out + .github/scripts/index.ts --input ./build > ./out/index.json + + - uses: robinraju/release-downloader@v1.11 + with: + latest: true + fileName: mash-*.sh + + - run: mv mash-*.sh ./out/mash.sh + + - name: build + run: .github/scripts/build.ts --input ./build --output ./out --index-json ./out/index.json + + - uses: actions/configure-pages@v4 + - uses: actions/upload-pages-artifact@v3 + with: + path: out + + deploy: + needs: build + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + steps: + - uses: actions/deploy-pages@v4 + id: deployment diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f2d2a15..cdad3de 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,57 +1,43 @@ +name: cd·vx + on: - push: - branches: main - paths: - - .github/workflows/deploy.yml - - .github/scripts/* - - scripts/* - pull_request: - paths: - - .github/workflows/deploy.yml - schedule: - - cron: '23 * * * *' - workflow_dispatch: + release: + types: + - published concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: cd/vx/${{ github.event.release.tag_name }} cancel-in-progress: true +permissions: + contents: write + jobs: - build: + retag: if: github.repository == 'pkgxdev/mash' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: pkgxdev/setup@v3 + - uses: fischerscode/tagger@v0 + with: + prefix: v + - run: | + git tag -f latest + git push origin latest --force - - name: trawl - run: .github/scripts/trawl.ts --out ./build - env: - GH_TOKEN: ${{ github.token }} + attach: + if: github.repository == 'pkgxdev/mash' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - - name: index + - name: version + run: sed -i s/mash 0.0.0-dev/mash ${{ github.event.release.tag_name }}/g ./mash + + - name: prep run: | mkdir out - .github/scripts/index.ts --input ./build > ./out/index.json - - - name: build - run: .github/scripts/build.ts --input ./build --output ./out --index-json ./out/index.json - - - uses: actions/configure-pages@v4 - - uses: actions/upload-pages-artifact@v3 - with: - path: out + mv ./mash ./out/mash-${{ github.event.release.tag_name }}.sh - deploy: - needs: build - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' }} - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - steps: - - uses: actions/deploy-pages@v4 - id: deployment + - name: attach + run: gh release upload ${{ github.event.release.tag_name }} ./out/mash-${{ github.event.release.tag_name }}.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f495592..4249f6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,12 @@ +name: ci + on: pull_request: paths: mash jobs: test: + if: github.repository == 'pkgxdev/mash' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/installer.sh b/installer.sh index d22faaa..0ba5965 100755 --- a/installer.sh +++ b/installer.sh @@ -26,17 +26,8 @@ fi if [ $# -gt 0 ]; then exec pkgx +pkgx.sh/mash -- mash "$@" else - pkgx install mash - - if [ -f /usr/bin/which ]; then - pkgxd="$(dirname "$(which pkgx)")" - - if [ ! -w "$pkgxd" ]; then - SUDO=sudo - fi - - $SUDO mv $HOME/.local/bin/mash "$pkgxd" - fi - + tmp="$(mktemp)" + curl -Ssf https://pkgxdev.github.io/mash/mash.sh > $tmp + sudo install -m 0755 "$tmp" /usr/local/bin/mash echo "now type: mash" 1>&2 fi diff --git a/mash b/mash index 286c8ee..c485384 100755 --- a/mash +++ b/mash @@ -2,6 +2,11 @@ set -eo pipefail +if [ "$1" == --version ]; then + echo "mash 0.0.0-dev" + exit 0 +fi + if [ -n "$RUNNER_DEBUG" -a -n "$GITHUB_ACTIONS" ] || [ -n "$VERBOSE" ]; then set -x fi