0x78f1935 Opened refs/heads/master #117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the main file of the github action workflow, | |
name: A Proxy Relay build | |
run-name: ${{ github.actor }} Opened ${{ github.ref }} | |
on: | |
# Trigger build(s) on specified branch, git action: | |
pull_request: | |
types: [opened, closed, synchronize] | |
branches: | |
- 'development' | |
- 'master' | |
jobs: | |
flake: | |
if: | | |
github.event_name == 'pull_request' && | |
!github.ref_protected && | |
!github.event.pull_request.merged && | |
github.ref != 'development' && | |
github.ref != 'staging' && | |
github.ref != 'master' && | |
github.ref != 'refs/heads/development' && | |
github.ref != 'refs/heads/master' && | |
github.event.action != 'closed' | |
uses: ./.github/workflows/test_python_flake.yaml | |
secrets: inherit | |
unittest: | |
needs: | |
- flake | |
uses: ./.github/workflows/test_python_tests.yaml | |
secrets: inherit | |
approve_development: | |
needs: | |
- flake | |
- unittest | |
uses: ./.github/workflows/auto_approve.yaml | |
secrets: inherit | |
deployment_question: | |
if: | | |
github.event_name == 'pull_request' && | |
github.event.pull_request.merged == true && | |
github.ref == 'refs/heads/development' && | |
github.event.action == 'closed' | |
runs-on: self-hosted | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: string | |
uses: ASzc/change-string-case-action@v5 | |
with: | |
string: ${{github.event.repository.name}} | |
- name: Create Pull Request | |
id: cpr | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const result = await github.rest.pulls.create({ | |
title: 'Deploy A Proxy Relay Package? - ${{ github.run_number }}', | |
owner, | |
repo, | |
head: '${{ github.ref_name }}', | |
base: 'master', | |
body: [ | |
'Would you like to release a new build of aproxyrelay ?\n', | |
'Update A Proxy Relay to latest', | |
'---', | |
'Build and release new version!', | |
].join('\n'), | |
assignees: '@0x78f1935', | |
reviewers: '@0x78f1935', | |
}); | |
github.rest.issues.addLabels({ | |
owner, | |
repo, | |
issue_number: result.data.number, | |
labels: ['docker', 'automated', 'prod-deployment'], | |
}); | |
const os = require("os"); | |
const fs = require("fs"); | |
function setOutput(key, value) { | |
// Temporary hack until core actions library catches up with github new recommendations | |
const output = process.env['GITHUB_OUTPUT'] | |
fs.appendFileSync(output, `${key}=${value}${os.EOL}`) | |
}; | |
setOutput('pr_id', result.data.number); | |
deploy_package: | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'prod-deployment') | |
timeout-minutes: 30 | |
runs-on: self-hosted | |
environment: production | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- id: string | |
uses: ASzc/change-string-case-action@v5 | |
with: | |
string: ${{github.event.repository.name}} | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- name: Install dependencies | |
run: python3.11 -m pip install --upgrade pip setuptools wheel | |
- name: Build and Publish | |
run: | | |
python3.11 -m build | |
python3.11 -m twine upload --repository pypi dist/* | |
env: | |
CUSTOM_VERSION: 1.${{ github.run_number }}.${{ github.run_attempt }}.rc${{ github.run_id }} | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_RELEASE_TOKEN }} | |
- name: Create a Release | |
id: release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/aproxyrelay-*.tar.gz,dist/aproxyrelay-*.whl" | |
bodyFile: "README.md" | |
generateReleaseNotes: true | |
makeLatest: true | |
token: ${{ secrets.PERSONAL_GITHUB_ACTIONS_TOKEN }} | |
tag: 1.${{ github.run_number }}.${{ github.run_attempt }}.rc${{ github.run_id }}+${{ steps.date.outputs.date }} |