Skip to content

Commit

Permalink
Merge pull request #82 from autometrics-dev/workflow-dispatch
Browse files Browse the repository at this point in the history
Switch to using workflow dispatch
  • Loading branch information
actualwitch authored Aug 24, 2023
2 parents 4157e97 + ce966de commit 4c29e5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
12 changes: 7 additions & 5 deletions .github/actions/get-release-version/get-release-version.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const branchName = process.env.GITHUB_REF;
const regex = /release\/([\d.]+)/gm;
const fs = require("fs");
const path = require("path");
const regex = /version = "([\d.]+)"/gm;

const matches = regex.exec(branchName);
const file_path = path.join(process.env.GITHUB_WORKSPACE, "pyproject.toml");
const file_contents = fs.readFileSync(file_path, { encoding: "utf8" });
const matches = regex.exec(file_contents);
if (matches && matches.length == 2) {
const [_, version] = matches;
const fs = require("fs");

fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}`, {
encoding: "utf8",
});
} else {
throw new Error(`No version found in release title: ${input_title}`);
throw new Error(`No version found in ${file_path}`);
}
24 changes: 8 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# This workflow will only run on prs from the release/* branch that were merged
name: Release
on:
pull_request:
types:
- closed
branches:
- "release/**"
on: [workflow_dispatch]

permissions:
contents: write

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,20 +25,19 @@ jobs:
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git switch main
git pull
git fetch origin main
git checkout main
git tag ${{ steps.release_version.outputs.version }}
git push origin ${{ steps.release_version.outputs.version }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: ${{ steps.release_version.outputs.version}}
draft: true
generate_release_notes: true
name: ${{ steps.release_version.outputs.version}}
# - name: Publish
# run: poetry run twine upload dist/*
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Publish
run: poetry run twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

0 comments on commit 4c29e5b

Please sign in to comment.