kill-the-newsletter/.github/workflows/main.yml

140 lines
6.1 KiB
YAML
Raw Normal View History

2020-03-18 20:34:23 +01:00
on: push
jobs:
2021-03-09 23:04:05 +01:00
insiders-build:
strategy:
matrix:
os: [windows, macos, ubuntu]
include:
- os: windows
2021-09-04 14:36:10 +02:00
build: npx caxa --directory . --command "{{caxa}}/node_modules/.bin/node" "{{caxa}}/distribution/index.js" --output "kill-the-newsletter--windows--${{ github.sha }}.exe"
2021-03-18 12:04:43 +01:00
artifact: kill-the-newsletter--windows--${{ github.sha }}.exe
2021-03-09 23:04:05 +01:00
- os: macos
build: |
2021-09-04 14:36:10 +02:00
npx caxa --directory . --command "{{caxa}}/node_modules/.bin/node" "{{caxa}}/distribution/index.js" --output "kill-the-newsletter"
2021-03-18 12:04:43 +01:00
tar -czf "kill-the-newsletter--macos--${{ github.sha }}.tgz" "kill-the-newsletter"
artifact: kill-the-newsletter--macos--${{ github.sha }}.tgz
2021-03-09 23:04:05 +01:00
- os: ubuntu
build: |
2021-09-04 14:36:10 +02:00
npx caxa --directory . --command "{{caxa}}/node_modules/.bin/node" "{{caxa}}/distribution/index.js" --output "kill-the-newsletter"
2021-03-15 00:17:07 +01:00
tar -czf "kill-the-newsletter--linux--${{ github.sha }}.tgz" "kill-the-newsletter"
artifact: kill-the-newsletter--linux--${{ github.sha }}.tgz
2021-03-09 23:04:05 +01:00
runs-on: ${{ matrix.os }}-latest
2020-03-18 20:34:23 +01:00
steps:
2022-10-13 22:06:00 +02:00
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
2020-12-22 21:00:32 +01:00
with:
2022-10-18 19:03:29 +02:00
node-version: 19
2021-03-09 23:04:05 +01:00
- run: |
npm ci
${{ matrix.build }}
2022-10-13 22:06:00 +02:00
- uses: actions/upload-artifact@v3
2021-03-09 23:04:05 +01:00
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
test:
strategy:
matrix:
os: [windows, macos, ubuntu]
runs-on: ${{ matrix.os }}-latest
steps:
2022-10-13 22:06:00 +02:00
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
2020-03-19 18:46:45 +01:00
with:
2022-10-18 19:03:29 +02:00
node-version: 19
2020-03-18 20:34:23 +01:00
- run: npm install-ci-test
2021-03-09 23:04:05 +01:00
deploy:
2021-08-01 17:56:15 +02:00
if: github.ref == 'refs/heads/main'
2021-03-09 23:04:05 +01:00
needs: [insiders-build, test]
runs-on: ubuntu-latest
steps:
2022-10-13 22:06:00 +02:00
- uses: webfactory/ssh-agent@v0.5.4
2021-03-09 23:04:05 +01:00
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
2022-10-13 22:06:00 +02:00
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
2021-03-09 23:04:05 +01:00
with:
2021-03-15 00:17:07 +01:00
name: kill-the-newsletter--linux--${{ github.sha }}.tgz
2021-03-09 23:04:05 +01:00
- run: |
2021-03-15 00:17:07 +01:00
tar -xzf kill-the-newsletter--linux--${{ github.sha }}.tgz
2021-03-09 23:04:05 +01:00
cat >> ~/.ssh/known_hosts << "EOF"
2021-03-16 01:42:48 +01:00
kill-the-newsletter.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBQiZK4dxdZl6d6f2gpQxuVcwqvJo9JcnoEgfJ4fNjbY
kill-the-newsletter.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDNZ75UdvVaHOk86fF1TslxKWCGsRG7EfF4Rq2TqeZ1ZWbjc89gpl2G0jVQ1hSwo0KhvmZkpXJsCgQaOnR7kDMjHLdvnwGb6Uqnolef4LqZlso3i3L0dMxbHsBtq/laC1/Zk/sWXs2UO1oZaMNrjqaf+1CjUdkSQFFMoF8oVdgfg3SAidRs+8/WdZbfAjEfDqYONKk1iMRPUTVtN5H4LSJUpJsPx+T8QrDpRez820A3WLAxVbIdVU42Fa1VI8J+C/0Z6/iJcF6/7HRp1zcUWILFPu4t5VzBFVtaVSgkm29TiGfZiz8X/YFF+GRCW+Ht5bObDOEDFNLdrY/xyyqp3h0b9zSTUC5xKqugIiewUtULIT6W9cXxJdbW56W9jlRIlzHfzsB/rcXQC/+HIHWQsJYCF3LCE6JR+R9UfsSV2pR1TseA/9ARD5A2I//cXGxkDyTnWVdcxiHUQbWWq/B+pnfi+EwG0HTUgZWOH9pHJ3apGnHmudii6MAnFplMMzv8ULU=
kill-the-newsletter.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO5UFbB8oNfTXEYFpvykTCrlyeEFSMpAWKa5Nfc0hid2fr1t26rG9t/7DZk2J7MAyvbZecDVY9XGA+ku3RdO/qs=
2021-03-09 23:04:05 +01:00
EOF
2021-03-15 00:17:07 +01:00
ssh root@kill-the-newsletter.com "mkdir -p kill-the-newsletter"
rsync -a kill-the-newsletter root@kill-the-newsletter.com:kill-the-newsletter/kill-the-newsletter
rsync -a deployment-example/configuration.js root@kill-the-newsletter.com:kill-the-newsletter/configuration.js
rsync -a deployment-example/kill-the-newsletter.service root@kill-the-newsletter.com:/etc/systemd/system/kill-the-newsletter.service
2021-03-09 23:04:05 +01:00
2021-03-15 00:17:07 +01:00
ssh root@kill-the-newsletter.com << "EOF"
2021-03-09 23:04:05 +01:00
systemctl daemon-reload
2021-03-15 00:17:07 +01:00
systemctl enable kill-the-newsletter
systemctl restart kill-the-newsletter
2021-03-09 23:04:05 +01:00
EOF
npm-publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
steps:
2022-10-13 22:06:00 +02:00
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
2021-03-09 23:04:05 +01:00
with:
2022-10-18 19:03:29 +02:00
node-version: 19
2021-03-09 23:04:05 +01:00
registry-url: https://registry.npmjs.org/
- run: npm ci && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [insiders-build, test]
runs-on: ubuntu-latest
steps:
2022-10-13 22:06:00 +02:00
- uses: actions/download-artifact@v3
2021-03-09 23:04:05 +01:00
with:
2021-03-18 12:04:43 +01:00
name: kill-the-newsletter--windows--${{ github.sha }}.exe
2022-10-13 22:06:00 +02:00
- uses: actions/download-artifact@v3
2021-03-09 23:04:05 +01:00
with:
2021-03-18 12:04:43 +01:00
name: kill-the-newsletter--macos--${{ github.sha }}.tgz
2022-10-13 22:06:00 +02:00
- uses: actions/download-artifact@v3
2021-03-09 23:04:05 +01:00
with:
2021-03-15 00:17:07 +01:00
name: kill-the-newsletter--linux--${{ github.sha }}.tgz
2021-03-09 23:04:05 +01:00
- run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
id: tag
- uses: actions/create-release@v1
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: Release ${{ steps.tag.outputs.tag }}
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
2021-03-18 12:04:43 +01:00
asset_path: kill-the-newsletter--windows--${{ github.sha }}.exe
asset_name: kill-the-newsletter--windows--${{ steps.tag.outputs.tag }}.exe
2021-03-09 23:04:05 +01:00
asset_content_type: application/vnd.microsoft.portable-executable
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
2021-03-18 12:04:43 +01:00
asset_path: kill-the-newsletter--macos--${{ github.sha }}.tgz
asset_name: kill-the-newsletter--macos--${{ steps.tag.outputs.tag }}.tgz
2021-03-09 23:04:05 +01:00
asset_content_type: application/gzip
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
2021-03-15 00:17:07 +01:00
asset_path: kill-the-newsletter--linux--${{ github.sha }}.tgz
asset_name: kill-the-newsletter--linux--${{ steps.tag.outputs.tag }}.tgz
2021-03-09 23:04:05 +01:00
asset_content_type: application/gzip