ci(releases): refactor to use non-outdated actions

This commit is contained in:
Nicolas Meienberger 2023-11-28 09:05:53 +01:00
parent bffa31c0b7
commit 37c551da1f
4 changed files with 94 additions and 103 deletions

View file

@ -11,19 +11,20 @@ jobs:
create-tag: create-tag:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tagname: ${{ steps.create_tag.outputs.tagname }} tagname: ${{ steps.get_tag.outputs.tagname }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Create Tag - name: Get tag from package.json
id: create_tag id: get_tag
uses: Klemensas/action-autotag@stable run: |
VERSION=$(npm run version --silent)
echo "tagname=v${VERSION}-alpha.${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
- uses: rickstaa/action-create-tag@v1
with: with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tag: ${{ steps.get_tag.outputs.tagname }}
tag_prefix: 'v'
tag_suffix: '-alpha.${{ github.event.inputs.tag }}'
build-worker: build-worker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -144,25 +145,21 @@ jobs:
name: cli name: cli
path: cli path: cli
- name: Rename CLI
run: |
mv cli/bin/cli-x64 ./runtipi-cli-linux-x64
- name: Create alpha release - name: Create alpha release
id: create_release id: create_release
uses: actions/create-release@v1 uses: softprops/action-gh-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
body: | body: |
**${{ needs.create-tag.outputs.tagname }}** **${{ needs.create-tag.outputs.tagname }}**
tag_name: ${{ needs.create-tag.outputs.tagname }} tag_name: ${{ needs.create-tag.outputs.tagname }}
release_name: ${{ needs.create-tag.outputs.tagname }} name: ${{ needs.create-tag.outputs.tagname }}
draft: false draft: false
prerelease: true prerelease: true
files: |
- name: Upload X64 Linux CLI binary to release runtipi-cli-linux-x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cli/bin/cli-x64
asset_name: runtipi-cli-linux-x64
asset_content_type: application/octet-stream

View file

@ -11,18 +11,20 @@ jobs:
create-tag: create-tag:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tagname: ${{ steps.create_tag.outputs.tagname }} tagname: ${{ steps.get_tag.outputs.tagname }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Create Tag - name: Get tag from package.json
id: create_tag id: get_tag
uses: Klemensas/action-autotag@stable run: |
VERSION=$(npm run version --silent)
echo "tagname=v${VERSION}-beta.${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
- uses: rickstaa/action-create-tag@v1
with: with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tag: ${{ steps.get_tag.outputs.tagname }}
tag_prefix: 'v'
tag_suffix: '-beta.${{ github.event.inputs.tag }}'
build-worker: build-worker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -144,38 +146,26 @@ jobs:
name: cli name: cli
path: cli path: cli
- name: Rename CLI
run: |
mv cli/bin/cli-x64 ./runtipi-cli-linux-x64
mv cli/bin/cli-arm64 ./runtipi-cli-linux-arm64
- name: Create beta release - name: Create beta release
id: create_release id: create_release
uses: actions/create-release@v1 uses: softprops/action-gh-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
body: | body: |
**${{ needs.create-tag.outputs.tagname }}** **${{ needs.create-tag.outputs.tagname }}**
tag_name: ${{ needs.create-tag.outputs.tagname }} tag_name: ${{ needs.create-tag.outputs.tagname }}
release_name: ${{ needs.create-tag.outputs.tagname }} name: ${{ needs.create-tag.outputs.tagname }}
draft: false draft: false
prerelease: true prerelease: true
files: |
- name: Upload X64 Linux CLI binary to release runtipi-cli-linux-x64
uses: actions/upload-release-asset@v1 runtipi-cli-linux-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cli/bin/cli-x64
asset_name: runtipi-cli-linux-x64
asset_content_type: application/octet-stream
- name: Upload ARM64 Linux CLI binary to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cli/bin/cli-arm64
asset_name: runtipi-cli-linux-arm64
asset_content_type: application/octet-stream
e2e-tests: e2e-tests:
needs: [create-tag, publish-release] needs: [create-tag, publish-release]

View file

@ -72,9 +72,6 @@ jobs:
run: | run: |
while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "echo 'SSH is ready'"; do sleep 5; done while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "echo 'SSH is ready'"; do sleep 5; done
- name: Wait 1 minute for Droplet to be ready
run: sleep 60
- name: Create docker group on Droplet - name: Create docker group on Droplet
uses: fifsky/ssh-action@master uses: fifsky/ssh-action@master
with: with:
@ -85,6 +82,10 @@ jobs:
user: root user: root
key: ${{ secrets.SSH_KEY }} key: ${{ secrets.SSH_KEY }}
- name: Wait for dpkg lock to be released
run: |
while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "dpkg --configure -a"; do sleep 5; done
- name: Deploy app to Droplet - name: Deploy app to Droplet
uses: fifsky/ssh-action@master uses: fifsky/ssh-action@master
with: with:

View file

@ -3,28 +3,28 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
get-tag: create-tag:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build-images, build-cli]
outputs: outputs:
tag: ${{ steps.get_tag.outputs.tag }} tagname: ${{ steps.get_tag.outputs.tagname }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Node.js - name: Get tag from package.json
uses: actions/setup-node@v4
with:
node-version: 18
- name: Get tag from VERSION file
id: get_tag id: get_tag
run: | run: |
VERSION=$(npm run version --silent) VERSION=$(npm run version --silent)
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT echo "tagname=v${VERSION}" >> $GITHUB_OUTPUT
- uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.get_tag.outputs.tagname }}
build-images: build-images:
if: github.repository == 'runtipi/runtipi' if: github.repository == 'runtipi/runtipi'
needs: get-tag needs: create-tag
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -49,14 +49,45 @@ jobs:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.get-tag.outputs.tag }},ghcr.io/${{ github.repository_owner }}/runtipi:latest tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.create-tag.outputs.tagname }},ghcr.io/${{ github.repository_owner }}/runtipi:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache,mode=max cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache,mode=max
build-worker:
runs-on: ubuntu-latest
needs: create-tag
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images
uses: docker/build-push-action@v5
with:
context: .
file: ./packages/worker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/worker:${{ needs.create-tag.outputs.tagname }},ghcr.io/${{ github.repository_owner }}/worker:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/worker:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/worker:buildcache,mode=max
build-cli: build-cli:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
needs: get-tag needs: create-tag
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -90,7 +121,7 @@ jobs:
run: pnpm install run: pnpm install
- name: Set version - name: Set version
run: pnpm -r --filter cli set-version ${{ needs.get-tag.outputs.tag }} run: pnpm -r --filter cli set-version ${{ needs.create-tag.outputs.tagname }}
- name: Build CLI - name: Build CLI
run: pnpm -r --filter cli package run: pnpm -r --filter cli package
@ -101,22 +132,6 @@ jobs:
name: cli name: cli
path: packages/cli/dist path: packages/cli/dist
create-tag:
runs-on: ubuntu-latest
needs: [build-images, build-cli]
outputs:
tagname: ${{ steps.create_tag.outputs.tagname }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Tag
id: create_tag
uses: Klemensas/action-autotag@stable
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: 'v'
publish-release: publish-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [create-tag] needs: [create-tag]
@ -129,38 +144,26 @@ jobs:
name: cli name: cli
path: cli path: cli
- name: Rename CLI
run: |
mv cli/bin/cli-x64 ./runtipi-cli-linux-x64
mv cli/bin/cli-arm64 ./runtipi-cli-linux-arm64
- name: Create release - name: Create release
id: create_release id: create_release
uses: actions/create-release@v1 uses: softprops/action-gh-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
body: | body: |
**${{ needs.create-tag.outputs.tagname }}** **${{ needs.create-tag.outputs.tagname }}**
tag_name: ${{ needs.create-tag.outputs.tagname }} tag_name: ${{ needs.create-tag.outputs.tagname }}
release_name: ${{ needs.create-tag.outputs.tagname }} name: ${{ needs.create-tag.outputs.tagname }}
draft: false draft: false
prerelease: true prerelease: true
files: |
- name: Upload X64 Linux CLI binary to release runtipi-cli-linux-x64
uses: actions/upload-release-asset@v1 runtipi-cli-linux-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cli/bin/cli-x64
asset_name: runtipi-cli-linux-x64
asset_content_type: application/octet-stream
- name: Upload ARM64 Linux CLI binary to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: cli/bin/cli-arm64
asset_name: runtipi-cli-linux-arm64
asset_content_type: application/octet-stream
e2e-tests: e2e-tests:
needs: [create-tag, publish-release] needs: [create-tag, publish-release]