Skip to content

Commit f20d55c

Browse files
committed
test2
1 parent 7550868 commit f20d55c

File tree

1 file changed

+66
-64
lines changed

1 file changed

+66
-64
lines changed

.github/workflows/release.yml

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,87 @@ on:
44
push:
55
branches: [ master, release ]
66

7-
jobs:
8-
check_version:
7+
jobs:
8+
check_version:
99
name: "Check Version Tag"
1010
runs-on: ubuntu-20.04
11-
steps:
12-
- uses: actions/checkout@v3
13-
-
14-
continue-on-error: true
15-
env:
16-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
15+
- name: Get Latest Version Tag
1716
id: previoustag
18-
name: "Get Latest Version"
1917
uses: WyriHaximus/github-action-get-previous-tag@master
20-
-
21-
name: "Print Latest Version"
22-
run: "echo ${{ steps.previoustag.outputs.tag }}"
23-
-
18+
19+
- name: Print Latest Version
20+
run: echo "Latest tag: ${{ steps.previoustag.outputs.tag }}"
21+
22+
- name: Get Version from pubspec.yaml
2423
id: config
25-
name: "Get New Version"
2624
uses: CumulusDS/get-yaml-paths-action@v0.1.0
27-
with:
25+
with:
2826
file: pubspec.yaml
2927
version_name: version
30-
-
31-
name: "Print New Version"
32-
run: "echo ${{ steps.config.outputs.version_name }}"
33-
-
34-
if: "steps.config.outputs.version_name == steps.previoustag.outputs.tag"
35-
name: "Compare Version"
28+
29+
- name: Print New Version
30+
run: echo "New version from pubspec.yaml: ${{ steps.config.outputs.version_name }}"
31+
32+
- name: Compare Version
33+
if: steps.config.outputs.version_name == steps.previoustag.outputs.tag
3634
run: |
37-
echo 'The version from your pubspec.yaml is the same as Release, Please update the version'
38-
exit 1
39-
-
40-
run: "echo ${{ steps.config.outputs.version_name }} > version.txt"
41-
shell: bash
42-
-
43-
name: "Upload New Version"
35+
echo 'The version from pubspec.yaml is the same as the latest release tag. Please update the version.'
36+
exit 1
37+
38+
- name: Save New Version
39+
run: echo "${{ steps.config.outputs.version_name }}" > version.txt
40+
41+
- name: Upload New Version Artifact
4442
uses: actions/upload-artifact@v4
45-
with:
46-
name: home
43+
with:
44+
name: version
4745
path: version.txt
4846

49-
publish:
50-
needs:
51-
- check_version
47+
publish:
48+
needs: check_version
5249
runs-on: ubuntu-20.04
53-
steps:
54-
- name: Checkout
50+
steps:
51+
- name: Checkout Repository
5552
uses: actions/checkout@v3
56-
- name: Create Pub Credentials Folder
57-
run: mkdir -p ~/.pub-cache
58-
- name: Create Pub Credentials File
53+
54+
- name: Set up Flutter
55+
uses: subosito/flutter-action@v2
56+
with:
57+
flutter-version: stable
58+
59+
- name: Set Pub Credentials
5960
run: echo "${{ secrets.CREDENTIAL_JSON }}" > ~/.pub-cache/credentials.json
60-
- name: "Publish Package"
61-
uses: Omega365/actions-flutter-pub-publisher@master
62-
with:
63-
dry_run: false
64-
flutter_package: true
65-
skip_test: true
66-
67-
tag:
61+
62+
- name: Verify Pub Credentials File
63+
run: |
64+
if [ -f ~/.pub-cache/credentials.json ]; then
65+
echo "Credentials file exists."
66+
else
67+
echo "Credentials file not found!" && exit 1
68+
fi
69+
70+
- name: Publish Package to Pub
71+
run: flutter pub publish --force
72+
73+
tag:
6874
name: "Tag Version"
69-
needs:
70-
- publish
75+
needs: publish
7176
runs-on: ubuntu-20.04
72-
steps:
73-
-
74-
name: "Download New Version"
77+
steps:
78+
- name: Download New Version
7579
uses: actions/download-artifact@v4
76-
with:
77-
name: home
78-
-
79-
env:
80-
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
81-
name: "Set and Tag the new version"
82-
run: "echo \"::set-env name=RELEASE_VERSION::$(cat home/version.txt)\""
83-
shell: bash
84-
-
85-
uses: tvdias/github-tagger@v0.0.2
86-
with:
87-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
88-
tag: "${{env.RELEASE_VERSION}}"
80+
with:
81+
name: version
82+
83+
- name: Read and Tag New Version
84+
env:
85+
NEW_VERSION: ${{ steps.download-artifact.outputs.path }}
86+
run: |
87+
NEW_VERSION=$(cat version/version.txt)
88+
echo "Tagging version: $NEW_VERSION"
89+
git tag $NEW_VERSION
90+
git push origin $NEW_VERSION

0 commit comments

Comments
 (0)