Skip to content

Commit 1078a07

Browse files
committed
Add release workflow
1 parent a2f46bc commit 1078a07

2 files changed

Lines changed: 74 additions & 12 deletions

File tree

.github/workflows/build.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
strategy:
12-
fail-fast: false
12+
fail-fast: true
1313

1414
steps:
1515
# Repository
@@ -20,16 +20,7 @@ jobs:
2020
- name: Set up Pixi
2121
uses: prefix-dev/setup-pixi@v0.8.9
2222

23-
# Build
23+
# Test build (release workflow builds and uploads)
2424
- name: Build
2525
run: |
26-
pixi build
27-
28-
# Upload
29-
- name: Upload
30-
if: ${{ github.ref_name == 'dev' && github.repository_owner == 'Auto-Mech'}}
31-
run: |
32-
pixi run -e build upload
33-
env:
34-
ANACONDA_API_KEY: ${{ secrets.ANACONDA_API_KEY }}
35-
continue-on-error: true
26+
pixi build

.github/workflows/release.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: release
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
if: >
13+
github.event.pull_request.merged == true && (
14+
contains(github.event.pull_request.labels.*.name, 'release:patch') ||
15+
contains(github.event.pull_request.labels.*.name, 'release:major')
16+
)
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: true
20+
21+
steps:
22+
# 1. Checkout the merged code
23+
- name: Checkout merged code
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.pull_request.base.ref }}
27+
fetch-depth: 0
28+
29+
# 2. Setup environment
30+
- name: Set up Pixi
31+
uses: prefix-dev/setup-pixi@v0.8.9
32+
33+
- name: Fetch bot identity
34+
id: bot
35+
uses: raven-actions/bot-details@v1
36+
37+
- name: Configure git for committing
38+
run: |
39+
git config user.name "${{ steps.bot.outputs.name }}"
40+
git config user.email "${{ steps.bot.outputs.email }}"
41+
42+
# 3. Bump version
43+
- name: Bump version (patch)
44+
if: contains(github.event.pull_request.labels.*.name, 'release:patch')
45+
run: pixi run -e build bumpver update --patch
46+
47+
- name: Bump version (major)
48+
if: contains(github.event.pull_request.labels.*.name, 'release:major')
49+
run: pixi run -e build bumpver update --major
50+
51+
- name: Get version
52+
id: version
53+
run: |
54+
echo "tag=$(pixi run current-version)" >> "$GITHUB_OUTPUT"
55+
56+
# 4. Build and upload conda package
57+
- name: Build
58+
run: |
59+
pixi build
60+
61+
- name: Upload
62+
run: |
63+
pixi run -e build upload
64+
env:
65+
ANACONDA_API_KEY: ${{ secrets.ANACONDA_API_KEY }}
66+
67+
# 5. Create release
68+
- name: Create GitHub Release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ steps.version.outputs.tag }}

0 commit comments

Comments
 (0)