cd·bottle #21
This file contains hidden or 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: cd·bottle | |
| run-name: cd·bottle ${{inputs.pkgs}} | |
| on: | |
| push: | |
| branches: | |
| main | |
| paths: | |
| projects/**/*/build.ts | |
| workflow_dispatch: | |
| inputs: | |
| pkgs: | |
| required: true | |
| env: | |
| PKGX_DIST_URL: https://dist.tea.xyz/v2 | |
| jobs: | |
| ingest: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.computer.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/plan | |
| id: computer | |
| with: | |
| pkgs: ${{ github.event.inputs.pkgs }} | |
| bottle: | |
| needs: ingest | |
| runs-on: ${{ matrix.platform.os }} | |
| container: ${{ matrix.platform.container }} | |
| name: build ${{ matrix.pkg }} (${{ matrix.platform.tinyname }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.ingest.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup | |
| - run: pkg-build ${{ matrix.pkg }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - run: pkg-test ${{env.PROJECT}}=${{env.VERSION}} | |
| - run: | | |
| eval "$(pkgx +aws +deno +xz)" | |
| echo "$PATH" >> "$GITHUB_PATH" | |
| if: ${{ runner.os == 'Linux' }} | |
| - uses: denoland/setup-deno@v2 | |
| if: ${{ runner.os != 'Linux' }} | |
| - uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| # FIXME this uploads for each platform and even though it should be the same file—it’s lame | |
| - name: cp README | |
| run: | | |
| cd $PREFIX | |
| cd .. | |
| for x in README*; do | |
| aws s3 cp "$x" "s3://dist.tea.xyz/${{env.PROJECT}}/$x" | |
| done | |
| shell: bash | |
| if: ${{ runner.os != 'Windows' }} | |
| - name: bottle | |
| run: | | |
| OLDWD="$PWD" | |
| if [ $(uname) = Darwin ]; then | |
| # pkgx cannot untar into read only directories on macOS | |
| # NOTE the true fix would be to make the dirs writable when | |
| # untarring and then make them read only again after | |
| find "$PREFIX" -type f | xargs chmod -w | |
| else | |
| chmod -R -w "$PREFIX" | |
| fi | |
| cd $(mktemp -d) | |
| mkdir -p $PROJECT | |
| mv "$PREFIX" $PROJECT | |
| tar czf $OLDWD/v$VERSION.tar.gz * | |
| tar cJf $OLDWD/v$VERSION.tar.xz * | |
| shell: bash | |
| - name: s3 sync | |
| run: | | |
| aws s3 cp v${{env.VERSION}}.tar.gz s3://dist.tea.xyz/v2/${{env.PROJECT}}/${{env.PLATFORM}}/v${{env.VERSION}}.tar.gz | |
| aws s3 cp v${{env.VERSION}}.tar.xz s3://dist.tea.xyz/v2/${{env.PROJECT}}/${{env.PLATFORM}}/v${{env.VERSION}}.tar.xz | |
| deno run -A .github/scripts/generate-versions.ts v2/${{env.PROJECT}}/${{env.PLATFORM}} > versions.txt | |
| aws s3 cp versions.txt s3://dist.tea.xyz/v2/${{env.PROJECT}}/${{env.PLATFORM}}/versions.txt | |
| - name: cf invalidate | |
| run: | |
| aws cloudfront create-invalidation | |
| --distribution-id EWF6XUK8J11DP | |
| --paths | |
| /v2/${{ env.PROJECT }}/${{ env.PLATFORM }}/versions.txt | |
| /v2/${{ env.PROJECT }}/${{ env.PLATFORM }}/v${{env.VERSION}}.tar.gz | |
| /v2/${{ env.PROJECT }}/${{ env.PLATFORM }}/v${{env.VERSION}}.tar.xz |