publish: Rewrite as a separate layer

generated from commit 0b1ec49402aa9a8ccd1aebeac9e7468586168221