-
Notifications
You must be signed in to change notification settings - Fork 4
137 lines (115 loc) · 4.28 KB
/
git_package_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Git Package Release
on:
push:
branches: [ main ]
env:
flutter_version: '3.27.0'
java_version: 17
flutter_channel: 'stable'
ruby_version: '2.7.5'
release_version: '2.1.5'
PACKAGE_DIR: l10n_mapper_generator
jobs:
git_package_release:
name: Test & Release Packages
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.PACKAGE_DIR }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Ruby (Install and Cache bundle)
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.ruby_version }}
bundler-cache: true
working-directory: ${{ env.PACKAGE_DIR }}
- name: Setup Java 17
uses: actions/[email protected]
with:
java-version: ${{ env.java_version }}
distribution: 'zulu'
- name: Setup Flutter
uses: subosito/[email protected]
with:
flutter-version: ${{ env.flutter_version }}
channel: ${{ env.flutter_channel }}
cache: false
- name: Install dependencies
run: dart pub get
- name: Analyze
run: dart analyze
- name: Format check
run: dart format --set-exit-if-changed --line-length=120 .
- name: Get pubspec version
run: |
cat > get_version.dart << 'EOF'
import 'dart:io';
import 'package:yaml/yaml.dart';
void main() async {
final pubspecFile = File('pubspec.yaml');
final pubspecContent = await pubspecFile.readAsString();
final pubspec = loadYaml(pubspecContent);
print(pubspec['version']);
}
EOF
echo "PUBSPEC_VERSION=$(dart get_version.dart)" >> $GITHUB_ENV
- name: Create Release Notes
env:
BEFORE_REF: ${{ github.event.before }}
AFTER_REF: ${{ github.event.after }}
run: |
echo "$(git log --pretty=format:'%s: %an' $BEFORE_REF...$AFTER_REF)" >> release_notes.md
echo -e "\n$(date +'%Y-%m-%d')" >> release_notes.md
cat release_notes.md
- name: Setup pub.dev credentials
run: |
# Create the directory with proper permissions
mkdir -p ~/.pub-cache
# Write the credentials file with proper JSON formatting
# The EOF syntax preserves JSON structure and spacing
cat > ~/.pub-cache/credentials.json << 'EOF'
{
"accessToken": "${{ fromJson(secrets.CREDENTIAL_JSON).accessToken }}",
"refreshToken": "${{ fromJson(secrets.CREDENTIAL_JSON).refreshToken }}",
"tokenEndpoint": "https://accounts.google.com/o/oauth2/token",
"scopes": ["openid", "https://www.googleapis.com/auth/userinfo.email"],
"expiration": ${{ fromJson(secrets.CREDENTIAL_JSON).expiration }}
}
EOF
# Set restrictive permissions for security
chmod 600 ~/.pub-cache/credentials.json
# Verify the file exists and has correct structure
if [ -f ~/.pub-cache/credentials.json ]; then
echo "Credentials file created successfully"
# Check if file is valid JSON (will exit if invalid)
jq empty ~/.pub-cache/credentials.json
else
echo "Failed to create credentials file"
exit 1
fi
- name: Pub publish --dry-run
run: dart pub publish --dry-run
- name: Pub publish
run: |
# The -f flag forces publish without confirmation
# The --verify-only flag is removed from dart pub args
dart pub publish -f
# - name: Pub publish
# uses: k-paxian/[email protected]
# with:
# credentialJson: ${{ secrets.CREDENTIAL_JSON }}
# flutter: true
# skipTests: true
# force: false
# package_directory: l10n_mapper_generator
- name: Publish to Github Releases
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
# commit: ${{ vars.RELEASE_TARGET_BRANCH }}
# tag: ${{ env.PUBSPEC_VERSION }}.${{ github.run_number }}
tag: ${{ env.PUBSPEC_VERSION }}
makeLatest: true