Skip to content

Fix indentation in pub.dev credentials setup step #56

Fix indentation in pub.dev credentials setup step

Fix indentation in pub.dev credentials setup step #56

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