Skip to content

Commit 4c29e5b

Browse files
authored
Merge pull request #82 from autometrics-dev/workflow-dispatch
Switch to using workflow dispatch
2 parents 4157e97 + ce966de commit 4c29e5b

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
const branchName = process.env.GITHUB_REF;
2-
const regex = /release\/([\d.]+)/gm;
1+
const fs = require("fs");
2+
const path = require("path");
3+
const regex = /version = "([\d.]+)"/gm;
34

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

911
fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}`, {
1012
encoding: "utf8",
1113
});
1214
} else {
13-
throw new Error(`No version found in release title: ${input_title}`);
15+
throw new Error(`No version found in ${file_path}`);
1416
}

.github/workflows/release.yml

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
# This workflow will only run on prs from the release/* branch that were merged
21
name: Release
3-
on:
4-
pull_request:
5-
types:
6-
- closed
7-
branches:
8-
- "release/**"
2+
on: [workflow_dispatch]
93

104
permissions:
115
contents: write
126

137
jobs:
148
release:
15-
if: github.event.pull_request.merged == true
169
runs-on: ubuntu-latest
1710
steps:
1811
- uses: actions/checkout@v3
@@ -32,20 +25,19 @@ jobs:
3225
run: |
3326
git config --local user.email "github-actions[bot]@users.noreply.github.com"
3427
git config --local user.name "github-actions[bot]"
35-
git switch main
36-
git pull
28+
git fetch origin main
29+
git checkout main
3730
git tag ${{ steps.release_version.outputs.version }}
3831
git push origin ${{ steps.release_version.outputs.version }}
3932
- name: Create release
4033
uses: softprops/action-gh-release@v1
4134
with:
4235
files: dist/*
4336
tag_name: ${{ steps.release_version.outputs.version}}
44-
draft: true
4537
generate_release_notes: true
4638
name: ${{ steps.release_version.outputs.version}}
47-
# - name: Publish
48-
# run: poetry run twine upload dist/*
49-
# env:
50-
# TWINE_USERNAME: __token__
51-
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
39+
- name: Publish
40+
run: poetry run twine upload dist/*
41+
env:
42+
TWINE_USERNAME: __token__
43+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)