Skip to content

Merge pull request #492 from Parallels/release/0.7.1 #12

Merge pull request #492 from Parallels/release/0.7.1

Merge pull request #492 from Parallels/release/0.7.1 #12

Workflow file for this run

name: Publish Release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- version.json
jobs:
check-version-change:
outputs:
changed: ${{ steps.check-version.outputs.result }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Check if version has changed
id: check-version
uses: actions/github-script@v6
with:
script: |
const version = '${{ github.event.inputs.version }}' || require('./version.json').version;
// Find a release for that version
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: `release-v${version}`,
}).catch(() => null);
// If the release exists, the version has not changed
if (release) {
console.log(`Version ${version} has an existing release`);
console.log(release.data.html_url);
core.summary.addLink(`Release v${version}`, release.data.html_url);
await core.summary.write();
return "false";
}
console.log(`Version ${version} does not have a release`);
return true;
release:
needs: check-version-change
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: "" # will be set in the workflow
outputs:
version: ${{ env.EXT_VERSION }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Packge builder
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
pip install -r requirements.txt
- name: Parse version from package.json
run: |
echo "EXT_VERSION=$(cat version.json | jq -r '.version')" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: cjlapao/rq-dashboard:${{ env.EXT_VERSION }},cjlapao/rq-dashboard:latest
- name: Build Python package
run: |
python -m build --sdist --wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
repository-url: https://upload.pypi.org/legacy/
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.EXT_VERSION }}
release_name: Release v${{ env.EXT_VERSION }}
body: |
Release v${{ env.EXT_VERSION }}
draft: false
prerelease: false