diff --git a/.github/workflows/TestReleaser.yml b/.github/workflows/TestReleaser.yml index 26db9e1..a4714aa 100644 --- a/.github/workflows/TestReleaser.yml +++ b/.github/workflows/TestReleaser.yml @@ -39,65 +39,27 @@ env: jobs: - test: + + Image: runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: 1 steps: - uses: actions/checkout@v2 - - run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt + - name: Build container image + run: docker build -t ghcr.io/pytooling/releaser -f releaser/Dockerfile releaser - - name: Single - uses: ./releaser + - name: Push container image + uses: ./with-post-step with: - rm: true - token: ${{ secrets.GITHUB_TOKEN }} - files: artifact-*.txt - - - name: List - uses: ./releaser - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: | - artifact-*.txt - README.md - - - name: Add artifacts/*.txt - run: | - mkdir artifacts - echo "Build some tool and generate some artifacts" > artifacts/artifact.txt - touch artifacts/empty_file.txt - - - name: Single in subdir - uses: ./releaser - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/artifact.txt - - - name: Add artifacts/*.md - run: | - echo "releaser hello" > artifacts/hello.md - echo "releaser world" > artifacts/world.md - - - name: Directory wildcard - uses: ./releaser - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/* - - - name: Add artifacts/subdir - run: | - mkdir artifacts/subdir - echo "Test recursive glob" > artifacts/subdir/deep_file.txt - - - name: Directory wildcard (recursive) - uses: ./releaser - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/** + main: | + echo '${{ github.token }}' | docker login ghcr.io -u GitHub-Actions --password-stdin + docker push ghcr.io/pytooling/releaser + post: docker logout ghcr.io - test-composite: - needs: test + Composite: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -153,3 +115,66 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} files: artifacts/** + + + Test: + needs: + - Image + - Composite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt + + - name: Single + uses: ./releaser + with: + rm: true + token: ${{ secrets.GITHUB_TOKEN }} + files: artifact-*.txt + + - name: List + uses: ./releaser + with: + token: ${{ secrets.GITHUB_TOKEN }} + use-gh-cli: true + files: | + artifact-*.txt + README.md + + - name: Add artifacts/*.txt + run: | + mkdir artifacts + echo "Build some tool and generate some artifacts" > artifacts/artifact.txt + touch artifacts/empty_file.txt + + - name: Single in subdir + uses: ./releaser + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: artifacts/artifact.txt + + - name: Add artifacts/*.md + run: | + echo "releaser hello" > artifacts/hello.md + echo "releaser world" > artifacts/world.md + + - name: Directory wildcard + uses: ./releaser + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: artifacts/* + + - name: Add artifacts/subdir + run: | + mkdir artifacts/subdir + echo "Test recursive glob" > artifacts/subdir/deep_file.txt + + - name: Directory wildcard (recursive) + uses: ./releaser + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: artifacts/** + + diff --git a/releaser/Dockerfile b/releaser/Dockerfile index 2290f49..728c35c 100644 --- a/releaser/Dockerfile +++ b/releaser/Dockerfile @@ -1,4 +1,12 @@ FROM python:3.9-slim-bullseye COPY releaser.py /releaser.py -RUN pip install PyGithub --progress-bar off +RUN pip install PyGithub --progress-bar off \ + && apt update -qq \ + && apt install -y curl \ + && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ + dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \ + tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update -qq \ + && apt install -y gh CMD ["/releaser.py"] diff --git a/releaser/README.md b/releaser/README.md index 16d3711..4ff6d9a 100644 --- a/releaser/README.md +++ b/releaser/README.md @@ -26,7 +26,7 @@ However, those Actions were contributed by an employee in spare time, not offici Therefore, they were unmaintained before GitHub Actions was out of the private beta (see [actions/upload-release-asset#58](https://github.com/actions/upload-release-asset/issues/58)) and, a year later, archived. Those Actions are based on [actions/toolkit](https://github.com/actions/toolkit)'s hydrated version of octokit.js. -From a practical point of view, [actions/github-script](https://github.com/actions/github-script) is the natural replacement to those Actions, since it allows to use a pre-authenticated octokit.js client along with the workflow run context. +From a practical point of view, [actions/github-script](https://github.com/actions/github-script) is the natural replacement to those Actions, since it allows to use a pre-authenticated *octokit.js* client along with the workflow run context. Still, it requires writing plain JavaScript. Alternatively, there are non-official GitHub API libraries available in other languages (see [docs.github.com: rest/overview/libraries](https://docs.github.com/en/rest/overview/libraries)). @@ -72,7 +72,7 @@ jobs: # Update tag and pre-release # - Update (force-push) tag to the commit that is used in the workflow. # - Upload artifacts defined by the user. - - uses: pyTooling/Actions/releaser@main + - uses: pyTooling/Actions/releaser@r0 with: token: ${{ secrets.GITHUB_TOKEN }} files: | @@ -117,7 +117,7 @@ Note: ### Composite Action The default implementation of **Releaser** is a Container Action. -Therefore, in each run, the container image is built before starting the job. +Therefore, a pre-built container image is pulled before starting the job. Alternatively, a Composite Action version is available: `uses: pyTooling/Actions/releaser/composite@main`. The Composite version installs the dependencies on the host (the runner environment), instead of using a container. Both implementations are functionally equivalent from **Releaser**'s point of view; however, the Composite Action allows users diff --git a/releaser/action.yml b/releaser/action.yml index 897e506..3ae3fba 100644 --- a/releaser/action.yml +++ b/releaser/action.yml @@ -46,4 +46,4 @@ inputs: default: false runs: using: 'docker' - image: 'Dockerfile' + image: 'docker://ghcr.io/pytooling/releaser'