Skip to content

Commit f640285

Browse files
automate release process (#54)
1 parent 369ce25 commit f640285

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

.github/workflows/publish.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseNotes:
7+
description: 'Enter link to Release Notes, e.g. https://documentation.anyline.com/flutter-plugin-component/latest/release-notes.html#54-6-0-2025-02-17'
8+
required: true
9+
default: ''
10+
11+
jobs:
12+
publish:
13+
permissions:
14+
id-token: write
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
20+
- name: Setup dart SDK
21+
uses: dart-lang/setup-dart@v1
22+
23+
- name: Setup flutter SDK
24+
uses: flutter-actions/setup-flutter@54feb1e258158303e041b9eaf89314dcfbf6d38a
25+
26+
- name: Install dependencies
27+
run: dart pub get
28+
29+
- name: Publish on Pub.dev
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.PAT }}
32+
run: dart pub publish --force
33+
34+
release:
35+
runs-on: ubuntu-latest
36+
needs: publish
37+
steps:
38+
- name: Generate Release
39+
id: generate_release
40+
run: |
41+
TAG=${{github.ref_name}}
42+
TAG_VERSION=$(echo "$TAG" | sed 's/^v//')
43+
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
44+
45+
- name: Create GitHub Release
46+
id: create_release
47+
uses: actions/create-release@v1 # Use the create-release action
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token from secrets
50+
with:
51+
tag_name: ${{ github.ref_name }} # Use the generated tag name
52+
release_name: Anyline ${{ env.TAG_VERSION}} # Set the release name
53+
body: |
54+
[Release Notes](${{ github.event.inputs.releaseNotes }})
55+
draft: false # Publish the release immediately
56+
prerelease: false # Mark the release as a full release
57+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release Tagging Workflow
2+
3+
on:
4+
pull_request:
5+
types: [closed] # Trigger the workflow when a pull request is closed
6+
branches:
7+
- main # Only trigger for pull requests merged into the main branch
8+
9+
jobs:
10+
create_tag:
11+
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') # Run only if the PR is merged and the branch name starts with 'release/'
12+
runs-on: ubuntu-latest # Use the latest Ubuntu environment
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4 # Check out the repository
16+
17+
- name: Set up Git
18+
run: |
19+
git config user.name "${{ secrets.RELEASE_BOT_USERNAME }}" # Set Git username
20+
git config user.email "${{ secrets.RELEASE_BOT_EMAIL }}" # Set Git email
21+
22+
- name: Generate Tag
23+
id: generate_tag
24+
run: |
25+
BRANCH_NAME=${{github.event.pull_request.head.ref}}
26+
echo "Current branch name is: $BRANCH_NAME"
27+
TAG_NAME=$(echo "$BRANCH_NAME" | sed -E 's/^release\/(.*)$/v\1/')
28+
TAG_VERSION=$(echo "$BRANCH_NAME" | sed -E 's/^release\/(.*)$/\1/')
29+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
30+
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
31+
echo "VERSION=$TAG_NAME" >> $GITHUB_OUTPUT
32+
33+
- name: Push Tag
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.PAT }}
36+
run: |
37+
git tag ${{ env.TAG_NAME }} # Create the tag
38+
git push origin ${{ env.TAG_NAME }} # Push the tag to the repository

0 commit comments

Comments
 (0)