mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
releaser: build and use image ghcr.io/pytooling/releaser
This commit is contained in:
127
.github/workflows/TestReleaser.yml
vendored
127
.github/workflows/TestReleaser.yml
vendored
@@ -39,65 +39,27 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test:
|
|
||||||
|
Image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOCKER_BUILDKIT: 1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
- name: Push container image
|
||||||
uses: ./releaser
|
uses: ./with-post-step
|
||||||
with:
|
with:
|
||||||
rm: true
|
main: |
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
echo '${{ github.token }}' | docker login ghcr.io -u GitHub-Actions --password-stdin
|
||||||
files: artifact-*.txt
|
docker push ghcr.io/pytooling/releaser
|
||||||
|
post: docker logout ghcr.io
|
||||||
- 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/**
|
|
||||||
|
|
||||||
|
|
||||||
test-composite:
|
Composite:
|
||||||
needs: test
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -153,3 +115,66 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: artifacts/**
|
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/**
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
FROM python:3.9-slim-bullseye
|
FROM python:3.9-slim-bullseye
|
||||||
COPY releaser.py /releaser.py
|
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"]
|
CMD ["/releaser.py"]
|
||||||
|
|||||||
@@ -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.
|
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.
|
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.
|
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)).
|
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 tag and pre-release
|
||||||
# - Update (force-push) tag to the commit that is used in the workflow.
|
# - Update (force-push) tag to the commit that is used in the workflow.
|
||||||
# - Upload artifacts defined by the user.
|
# - Upload artifacts defined by the user.
|
||||||
- uses: pyTooling/Actions/releaser@main
|
- uses: pyTooling/Actions/releaser@r0
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: |
|
files: |
|
||||||
@@ -117,7 +117,7 @@ Note:
|
|||||||
### Composite Action
|
### Composite Action
|
||||||
|
|
||||||
The default implementation of **Releaser** is a Container 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`.
|
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.
|
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
|
Both implementations are functionally equivalent from **Releaser**'s point of view; however, the Composite Action allows users
|
||||||
|
|||||||
@@ -46,4 +46,4 @@ inputs:
|
|||||||
default: false
|
default: false
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'docker://ghcr.io/pytooling/releaser'
|
||||||
|
|||||||
Reference in New Issue
Block a user